分支
1 2
| $ git checkout br01 切换到分支 'br01'
|
1 2
| $ git checkout -b br02 切换到一个新分支 'br02'
|
所创建的分支,都是基于当前分支创建的,也可以指定分支创建。
1 2
| $ git checkout -b br03 br01 切换到一个新分支 'br03'
|
1 2 3 4 5
| $ git branch br01 br02 br03 * master
|
1 2 3 4 5
| $ git merge br01 更新 dacd44e..fb3440c Fast-forward 01.txt | 1 + 1 file changed, 1 insertion(+)
|
Fast-forward表示当前合并是快进模式,速度快,但删除分支后,会丢失分支信息。
1 2
| $ git branch -d br01 已删除分支 br01(曾为 fb3440c)。
|
建议禁用Fast forward模式,git会在merge时产生一个新的commit,从分支历史上就可以看出分支信息。
1 2 3 4
| $ git merge --no-ff br03 Merge made by the 'recursive' strategy. 01.txt | 1 + 1 file changed, 1 insertion(+)
|
1 2 3 4 5 6 7 8 9 10 11
| $ git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%ad) \ %C(bold blue)[%an]%Creset' --abbrev-commit --topo-order --date=short * e353f90 - (HEAD, master) Merge branch 'br03' (2014-12-24) [learnit] |\ | * fac7935 - (br03) 09 (2014-12-24) [learnit] |/ * fb3440c - 08 (2014-12-24) [learnit] * dacd44e - (br02) 04 (2014-12-24) [learnit] * 9cf50d9 - 03 (2014-12-24) [learnit] * 2e18697 - 02 (2014-12-24) [learnit] * 49805b0 - 添加01.txt文档 (2014-12-24) [learnit]
|
标签
1
| $ git tag v0.9 -m '版本0.9' HEAD~
|
1 2
| $ git tag -d v1.0 已删除 tag 'v1.0'(曾为 e353f90)
|
各种show
1 2 3 4 5 6 7
| $ git show HEAD commit e353f90b923056c4a77f87ec286f4643cabfe80b Merge: fb3440c fac7935 Author: learnit <higoge@gmail.com> Date: Wed Dec 24 15:22:05 2014 +0800
Merge branch 'br03'
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| $ git show br02 commit dacd44eb03e1f84cac2e34d8f1e1b0fb9c9e0b52 Author: learnit <higoge@gmail.com> Date: Wed Dec 24 14:11:59 2014 +0800
04
diff --git a/01.txt b/01.txt index 7e556fd..3b6f86c 100644 --- a/01.txt +++ b/01.txt @@ -1,3 +1,4 @@ line01 02 03 +04
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| $ git show v0.9 tag v0.9 Tagger: learnit <higoge@gmail.com> Date: Wed Dec 24 15:29:36 2014 +0800
版本0.9
commit fb3440ce1930ac61f342a48f1c7f3339148e69ea Author: learnit <higoge@gmail.com> Date: Wed Dec 24 15:10:14 2014 +0800
08
diff --git a/01.txt b/01.txt index 3b6f86c..f12be70 100644 --- a/01.txt +++ b/01.txt @@ -2,3 +2,4 @@ line01 02 03 04 +08
|
如果本文对你有所帮助,请小额赞助。
~~ EOF ~~