1. 程式人生 > >git pull and git rebase

git pull and git rebase

relevant article:
使用git fetch和git rebase處理多人開發同一分支的問題——azureternite
我先update sem.c,但有人update itoa.cpp並且比我先提交。

gir pull:

* 949238e (HEAD -> master) Merge branch 'master' of https://github.com/theArcticOcean/CLib (weistephen<weistephen@garmin.com>, Wed May 30 23:13:23 2018)
|\
| * c20582e (origin/master) :sparkles
: update itoa.cpp (weistephen<weistephen@garmin.com>, Wed May 30 22:36:21 2018) * | b04d196 :sparkles: update sem.c (weistephen<weistephen@garmin.com>, Wed May 30 22:47:02 2018) |/ * 519b6f8 :memo: update README.md (weistephen<weistephen@garmin.com>, Sat May 26 15:34:23 2018)

git rebase
關於git rebase,解釋是這樣的:git-rebase - Reapply commits on top of another base tip


因為伺服器上已經有了新的修改,我們想要做的事情就是將把那些修改拿過來,然後把我們的修改補上。
這正好符合rebase的場景。

Assume the following history exists and the current branch is "topic":

                     A---B---C topic
                    /
               D---E---F---G master


       From this point, the result of either of the following commands:

           git rebase master
           git rebase master topic

       would be:

                             A'--B'
--C' topic / D---E---F---G master

fetch 並且rebase

➜ CLib git:(master) git fetch
➜ CLib git:(master) git rebase
First, rewinding head to replay your work on top of it...
Applying: :sparkles: update sem.c
➜ CLib git:(master) git-tree

git-tree:

* 9044a50 (HEAD -> master) :sparkles: update sem.c (weistephen<weistephen@garmin.com>, Thu May 31 08:10:52 2018)
* c20582e (origin/master) :sparkles: update itoa.cpp (weistephen<weistephen@garmin.com>, Wed May 30 22:36:21 2018)
* 519b6f8 :memo: update README.md (weistephen<weistephen@garmin.com>, Sat May 26 15:34:23 2018)

git-tree的原型是
alias git-tree=”git log –graph –decorate –pretty=format:’%C(red)%h%C(yell ow)%d%C(reset) %s %C(green)(%an<%ae>, %cd)%C(reset)’ –abbrev-commit –date= local $*”