您的位置:首页 > 编程语言

GitHub入门与实践(2)掌握Git 2、分支操作

2016-02-12 23:08 531 查看
    1)显示分支一览表
        git branch

$ git branch
* master

    2) 创建、切换分支

        git checkout -b
$ git checkout -b feature-A
Switched to a new branch 'feature-A'
$ git branch feature-A
$ git checkout feature-A
$ git branch
* feature-A
master
<pre name="code" class="plain">        $ git add README.md
$ git commit -m "Add feature-A"
[feature-A 3bfe955] Add feature-A
1 file changed, 3 insertions(+), 1 deletion(-)
$ git checkout master
Switched to branch 'master'
$ git checkout -
Switched to branch 'feature-A'



    3)特性分支

集中实现单一特性(主题),除此之外不进行任何作业的分支。

    4)主干分支

        特性分支的原点,合并的终点。
        master分支。

    5)合并分支

        git merge
$ git checkout master
Switched to branch 'master'
$ git merge --no-ff feature-A
Merge made by the 'recursive' strategy.
README.md | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)


    6)以图表形式查看分支

        git log --graph
$ git log --graph
*   commit c86057c4c91d9ae4a841a9e80a1a971194103301
|\  Merge: 899bf31 3bfe955
| | Author: Wu Jian <Jamsonwoo@126.com>
| | Date:   Fri Feb 12 23:27:28 2016 +0800
| |
| |     Merge branch 'feature-A'
| |
| * commit 3bfe9559a43f5dd199b0b9b0fac615aabfd7aa8d
|/  Author: Wu Jian <Jamsonwoo@126.com>
|   Date:   Fri Feb 12 23:13:24 2016 +0800
|
|       Add feature-A
|
* commit 899bf3107f38542ea7a8cccc933abb3a420603b8
| Author: Wu Jian <Jamsonwoo@126.com>
| Date:   Fri Feb 12 22:42:31 2016 +0800
|
|     Add index
|
* commit 3f9014e2b31071d17f6d6d5ce144780a2e0dbf13
Author: Wu Jian <Jamsonwoo@126.com>
Date:   Fri Feb 12 22:17:23 2016 +0800

First commit
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  github git 读书笔记