github常用命令

Generating SSH Keys (创建SSH密钥)
https://help.github.com/articles/generating-ssh-keys#platform-linux

 

Create a repository (创建代码库)
https://help.github.com/articles/create-a-repo

 

Pull changes (下拉更改)
(local unchanged, remote changed.)

$ git remote add origin git@github.com:username/project.git

$ git pull origin master

         [#]succeed


Push changes (上推更改)
(local changed, remote unchanged.)

$ git add .

$ git commit -m "local commit"

$ git remote add origin git@github.com:username/project.git

$ git push origin master

         [#]succeed

 

Conflict resolution (解决代码冲突)
(local changed, remote changed.)

$ git add .

$ git commit -m "local commit"

$ git remote add origin git@github.com:username/project.git

$ git push origin master

         ! [rejected]

$ git pull origin master

         CONFLICT (content)

你的源码文件内容会变为:

<<<<<<< HEAD
your commit
=======
remote repository
>>>>>>> master

直接在源码文件内人为取舍代码。

然后再push:

$ git add .

$ git commit -m "local commit"

$ git push origin master

 

Download (下载代码)
$ git clone git://github.com/username/project.git 

这种情况下是不能push的。

 

参考:

Git/Github使用方法小记

http://artori.us/git-github-usage/

git - 简易指南

http://rogerdudler.github.io/git-guide/index.zh.html

如何高效利用GitHub - 阳志平

http://www.yangzhiping.com/tech/github.html

Pro Git book

http://git-scm.com/book/zh

posted on 2019-01-06 14:10  冰山上的博客  阅读(214)  评论(0编辑  收藏  举报