git branch 显示分支一览表
$ git branch
feature-A
fix-B
fix_b
* master
git checkout 创建、切换分支
$ git checkout feature-A
Switched to branch 'feature-A'
- <small>-b 快速创建一个新分支并切换到该分支:
$ git checkout -b feature-B
Switched to a new branch 'feature-B'
</small>
git merge 合并分支
$ git merge --no-ff feature-A
Merge made by the 'recursive' strategy.
hello.html | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 hello.html
- <small>--no-ff 为了在历史记录中明确记录下本次的分支合并,我们需要创建合并提交。因此,在合并时加上 --no--ff 参数。</small>
git log --graph 以图表的方式查看分支
$ git log --graph
* commit d4885fe157b5ff9ad3844c7da0e61b9a053db090
|\ Merge: d16f2f4 4f26d6e
| | Author: JannyHo <fung.w.chan@hotmail.com>
| | Date: Tue May 16 15:12:41 2017 +0800
| |
| | Merge branch 'feature-A'
| |
| * commit 4f26d6e1fdcd6587b0bffe2e8e058c32ed5bf9f8
| | Author: JannyHo <fung.w.chan@hotmail.com>
| | Date: Tue May 16 15:11:36 2017 +0800
| |
| | Add hello.html
| |
* | commit d16f2f466deab5d6a249e1bb3bab320224361c21
|\ \ Merge: d8b19ab 8340da0
| | | Author: JannyHo <fung.w.chan@hotmail.com>
| | | Date: Mon May 15 17:12:41 2017 +0800
| | |
| | | Merge branch "fix-B"
| | |
| * | commit 8340da0144bf0de4655721700b1ebff6c40861bb
| | | Author: JannyHo <fung.w.chan@hotmail.com>
| | | Date: Mon May 15 16:58:08 2017 +0800
| | |
| | | Fix B
| | |
* | | commit d8b19abc1e917c10071244d1e43f7c2f2404fb5e
|\ \ \ Merge: 9ba9239 04f1afd
| |/ / Author: JannyHo <fung.w.chan@hotmail.com>
|/| / Date: Mon May 15 16:47:59 2017 +0800
| |/
| | Merge branch 'feature-A'
| |
| * commit 04f1afd645ad1944302616f1e7d45ca2227f90c1
|/ Author: JannyHo <fung.w.chan@hotmail.com>
| Date: Mon May 15 16:36:25 2017 +0800
|
| Add feature-A
|
* commit 9ba9239561b2ba36c7b2be2c2378aecc09ca8db8
| Author: JannyHo <fung.w.chan@hotmail.com>
| Date: Mon May 15 16:25:51 2017 +0800
|
| Add index
|
* commit b1c8e4f86873a64ab70ccec70b8b4c5bc8f5385f
| Author: JannyHo <fung.w.chan@hotmail.com>
| Date: Mon May 15 15:19:32 2017 +0800
|
| commit README file
|
网友评论