github学习使用(四)
2013-01-06 13:23
393 查看
上一次的博客中写道了,创建项目的一个流程,这里还有一种情况就是当我当地有一个现成的文档,我想上传到github上面去怎么办。
其实这种情况github也已经为你想到了,大家可以看到当我们创建一个空的repos的时候上面会有两种情况给我们选择:
这里我们就直接按照上面的例子来操作我们的文件:具体的做法这里我做了一个例子,是我从大师哪里下载的一个项目,然后我先传到我的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看到这样的信息就可以证明你已经搞定了这一个项目。
基本上就是这么一个意思。
相关文章推荐
- 使用git和github管理自己的项目---基础操作学习
- 学习使用git和GitHub
- iOS 学习笔记七 【博爱手把手教你使用2016年gitHub Mac客户端】
- Github使用学习笔记(一)
- github的使用,转一下好好学习学习
- 学习使用GitHub
- Github使用学习
- github快速使用指南—git学习笔记
- Git & Github & BitBucket 学习使用
- Github使用学习笔记
- github快速使用指南—git学习笔记
- Github使用学习
- 零基础学习GitHub桌面版-7使用Hexo建站并更换主题
- 使用git和github管理自己的项目---基础操作学习
- Git与GitHub学习笔记(六)使用 Github Pages 管理项目文档
- 机器人进阶学习(四)---ssh,github的使用
- 学习使用github(一)
- 使用git和github管理自己的项目---基础操作学习
- GitHub基础学习-使用eclipse的EGit插件向GitHub上传项目文件的方法
- spring boot学习 - git及github使用