4
我對git很陌生,我想知道如何跟蹤分支歷史?如何顯示本地分支歷史記錄?
例如:
echo "update README in branch master" >> README.md
git commit -a -m"commit in branch master"
git checkout -b b1
echo "update README in branch b1" >> README.md
git commit -a -m"commit in branch b1"
git checkout master
git merge b1
git push
然後有人克隆此回購,如何顯示分支歷史?
git log --graph
* commit 4162ecc962aa020ec6294312e4f8eed63ca152d1
| Author: test1 <[email protected]>
| Date: Fri Feb 15 14:37:43 2013 +0900
|
| commit in branch b1
|
* commit 08e80fc644fa7ebb374a601e16533a8fc3578f88
| Author: test1 <[email protected]>
| Date: Fri Feb 15 14:37:04 2013 +0900
|
| commit in branch master
|
* commit 9d9649cdb409654616798d8feeb516738997e2e0
Author: test1 <[email protected]>
Date: Thu Feb 14 21:33:46 2013 -0800
Initial commit
我也看到了一些這樣的日誌:
* commit 2f49d77afe0708037eab1de3d216484d01f1c190
| Author: ericz <[email protected]>
| Date: Wed Feb 13 11:45:49 2013 -0800
|
| readme update
|
* commit 996214b87cce3473297ed0997ca567497271e05a
|\ Merge: a239b70 5269cd4
| | Author: ericz <[email protected]>
| | Date: Wed Feb 13 11:45:23 2013 -0800
| |
| | Merge branch 'master' of github.com:peers/peerjs
| |
| * commit 5269cd455f1522e88ab5a15228effe11665e6a89
| | Author: Eric Zhang <[email protected]>
| | Date: Wed Feb 13 09:47:05 2013 -0800
| |
| | Update README.md
| |
* | commit a239b706f294c469a5c6542ce7e6f5e60417445a
| | Author: ericz <[email protected]>
| | Date: Wed Feb 13 11:45:09 2013 -0800
| |
| | new exmales
| |
* | commit 0ce560d093637b3a17c7b5f1ab1de3f9c00bb888
|/ Author: ericz <[email protected]>
| Date: Wed Feb 13 11:02:33 2013 -0800
|
| simple chat example
這是如何發生的?
和如何繪製圖形是這樣的:
D---E-------F
/ \ \
B---C---G---H---I---J
/ \
A-------K---------------L--M
你的第一個例子太簡單了,所以'git'只以快進的方式應用補丁,沒有合併提交。你可以使用'git merge --no-ff'強制'git'創建合併提交,而不是快進。 – ydroneaud 2013-02-15 13:43:50