git Cheat Sheet

1. add changes
git add --all

 

2.commit changes and add note
git commit -m "<Description of changes>"

 

3. push change to the branch
git push origin master

git push xxx.git

 

4.when conflicts, pull changes from origin branch

git pull xxx.git

 

5. show difference

git remote

git diff origin/master > ~/CAA\ CODE/log/dif_3rd_Pty.log

 

6. switch branch

git checkout <branch_name>

 

7.pull from server

git pull origin <source_branch>

= fetch 

 

8.update, reset

git clean -d -f -f

git reset --hard <head~1>

 

9.revert

git reset --hard <commit-hash>
 git push -f origin master

 

10.conflict

head: your branch's newest version

master: where you merged from

 

begin

<<<<<<< HEAD
    my code
=======
    old code
>>>>>>> master

end

 

step1.

solution:

begin

 my code

end

 

step2.

commit 

 

11.

posted @ 2017-03-27 17:33  付小同  阅读(267)  评论(0编辑  收藏  举报