github学习使用(四)

34 篇文章 0 订阅
18 篇文章 0 订阅

上一次的博客中写道了,创建项目的一个流程,这里还有一种情况就是当我当地有一个现成的文档,我想上传到github上面去怎么办。

其实这种情况github也已经为你想到了,大家可以看到当我们创建一个空的repos的时候上面会有两种情况给我们选择:

Create a new repository on the command line

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:chenbinghuilove/python_redis.git
git push -u origin master

Push an existing repository from the command line

git remote add origin git@github.com:chenbinghuilove/python_redis.git
git push -u origin master

这里我们就直接按照上面的例子来操作我们的文件:具体的做法这里我做了一个例子,是我从大师哪里下载的一个项目,然后我先传到我的github上面给大家共享时:

root@zhou:~/.ssh# git clone git://github.com/nettedfish/redis-py.git
Cloning into 'redis-py'...
remote: Counting objects: 1906, done.
remote: Compressing objects: 100% (816/816), done.
remote: Total 1906 (delta 1278), reused 1690 (delta 1086)
Receiving objects: 100% (1906/1906), 316.57 KiB | 62 KiB/s, done.
Resolving deltas: 100% (1278/1278), done.
root@zhou:~/.ssh# ls
id_rsa  id_rsa.pub  known_hosts  Lovepython  Loveshell  redis-py
可以看到redis-py是我从别人的github上面下载的项目,下面我想要上传到我的github上面,首先要做的是先删掉当前.git这个文件,因为它存储的是别人的github信息,下面是我的具体操作:

root@zhou:~/.ssh/redis-py# ls -a
.   CHANGES  .gitignore  LICENSE      README.md  run_tests  tests
..  .git     INSTALL     MANIFEST.in  redis      setup.py   .travis.yml
root@zhou:~/.ssh/redis-py# git init
Reinitialized existing Git repository in /root/.ssh/redis-py/.git/
root@zhou:~/.ssh/redis-py# git remote add origin git@github.com:chenbinghuilove/python_redis.git
fatal: remote origin already exists.
root@zhou:~/.ssh/redis-py# rm -r .git
这个时候需要做的就是重新初始化一个git文件,并且将github上面的项目git文件给重置上去:
root@zhou:~/.ssh/redis-py# git init
Initialized empty Git repository in /root/.ssh/redis-py/.git/
root@zhou:~/.ssh/redis-py# git remote add origin git@github.com:chenbinghuilove/python_redis.git
这时别以为就可以直接push到github上面了,还要需要我们按照以前加载新文件那样重新操作一遍:

root@zhou:~/.ssh/redis-py# git push -u origin master
Enter passphrase for key '/root/.ssh/id_rsa': 
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:chenbinghuilove/python_redis.git'
root@zhou:~/.ssh/redis-py# ls
CHANGES  LICENSE      README.md  run_tests  tests
INSTALL  MANIFEST.in  redis      setup.py
root@zhou:~/.ssh/redis-py# ls -a
.   CHANGES  .gitignore  LICENSE      README.md  run_tests  tests
..  .git     INSTALL     MANIFEST.in  redis      setup.py   .travis.yml
root@zhou:~/.ssh/redis-py# git add .
root@zhou:~/.ssh/redis-py# git commit -a -m "study"
[master (root-commit) 4181414] study
 22 files changed, 5337 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 .travis.yml
 create mode 100644 CHANGES
root@zhou:~/.ssh/redis-py# git push -u origin master 
Enter passphrase for key '/root/.ssh/id_rsa': 
Counting objects: 26, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (25/25), done.
Writing objects: 100% (26/26), 46.42 KiB, done.
Total 26 (delta 0), reused 0 (delta 0)
To git@github.com:chenbinghuilove/python_redis.git
 * [new branch]      master -> master
看到这样的信息就可以证明你已经搞定了这一个项目。
基本上就是这么一个意思。








  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值