新建分支
$ git branch testing
切换到刚刚新建的分支
$ git checkout testing
做一些修改
$ vim test.rb
提交
$ git commit -a -m 'made other changes'
=========================================================================
假设此时项目需要修改,假设修改编号为 #iss53
新建 iss53分支并切换到此分支,注意 -b 参数
$ git checkout -b iss53
做一些修改
vim index.html
修改完成提交
$ git commit -a -m 'added a new footer [issue 53]'
对刚才的修改进行紧急合并
先切换到master
$ git checkout master
然后建立紧急修改分支并切换到此分支
git checkout -b 'hotfix'
做出与刚才 iss53一样的修改
vim index.html
提交修改
$ git commit -a -m 'fixed the broken email address'
再回到master
$ git checkout master
与 hotfix 合并分支合并,注意 git merge 语句为合并,本质是master指针后移
$ git merge hotfix
然后删掉合并分支 hotfix
$ git branch -d hotfix
现在可以回到 iss53 上继续推进
$ git checkout iss53
最后删掉 iss53
==================================================================================
分支的管理
查看有哪些分支
$ git branch
查看每个分支最后的更改
$ git branch -v
查看哪些分支已被并入当前分支
$ git branch --merged
查看尚未合并的工作
$ git branch --no-merged