github首页,找到下图界面,点击“new repository”按钮:
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image001.png
填下项目名称、描述、url等信息,然后提交。
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image002.png
图中标红的一项的意思是只有付费用户才有私有库托管服务,在github上开源(public)项目托管是免费的。
这样一个新的版本库就创建完毕了。
接下来我们需要本地版本库和远程版本库(github上的)进行通信,还需要一些配置。
2.ssh配置
想要让本地版本库与远程版本库通信,需要配置下SSHkey。
2.1检查计算机上是否已经有SSH key
1. $ cd ~/.ssh
如果出现““No such file ordirectory”或类似的语句,说明缺少ssh的key。
2.2创建个新的SSH key
1. $ ssh-keygen -t rsa -C "your_email@youremail.com"
比如明河机子上的
1. $ ssh-keygen -t rsa -C "minghe36@126.com"
会出现类似下图的提示:
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image003.png
直接按下“enter”键即可,然后输入密码。
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image004.png
一切顺利的话,你可以查看下c:\Users\Administrator\.ssh\id_rsa.pub文件,复制里面的key码。
2.3增加ssh key到github上
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image005.png
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image006.png
留意并不需要填写title,github会自动生成,直接把复制的key黏贴到key输入框确定即可。
2.4配置下git的用户名和email
1. $ git config --global user.name "minghe"
2. $ git config --global user.email "minghe36@126.com"
配置结束。
3.本地版本库和远程版本库的通信
3.1克隆个远程版本库
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image007.png
“cdd:\git-test”切换到该目录。
3.2推送更新到远程版本库
先随意提交个文件到版本库
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image008.png
由于是克隆远程版本库,已经存在远程分支origin,无需再创建。
(PS:创建远程分支:git remote addorigin
git@github.com:minghe/git-test.git)
查看远程分支情况,可以使用
git branch -r命令。
推送修改到远程版本库:
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image009.png
git push命名将推送内容到远程服务器。
与之相反的命令就是git pull。
git 提交修改到github上1,在GITHUB.com注册相应账号,建立Repositories。
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image010.png
3,克隆GitHub项目
git clone git://github.com/xxx/xxx.git
注:要转到file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image011.png在进行git bash操作
4,分支的创建和合并
# git branch local
# git checkout local 切换到local
注:这里的分支是在本地,没有在github服务器上建立分支。
5, 在local分支进行开发,开发完成后与master分支合并
# git checkout master
# git merge local
# git branch -d local 合并完后删除local
6,
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image013.png
7,
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image015.png
注:这时github还没有我添加的文件如:
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image017.png
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image018.png
8,用$ git pull 获取现在master的最新更改。因为我对README.md 做了修改。
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image019.png
9,最后将修改的内容提交到github服务器上。
$ git push origin master
定义远程服务器别名origin
# git remote add origin
git@github.com:xxx/new-project.git
最后成功。
file:///C:/Users/Youzh/AppData/Local/Temp/msohtmlclip1/01/clip_image021.png
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。