git创建和合并分支
branch(分支)
参考:廖雪峰git教程
Git鼓励大量使用分支:
查看分支:git branch
创建分支:git branch <name>
切换分支:git checkout <name>
创建+切换分支:git checkout -b <name>
合并某分支到当前分支:git merge <name>
删除分支:git branch -d <name>
步骤
$ git checkout -b mul
Switched to a new branch 'mul'
$ git branch
* mul
master
$ git add branch.md README.md stage.md
$ git commit -m "new knowledge about git"
$ git checkout master
Switched to branch 'master'
$ git merge mul
Updating b281dda..8186c3a
Fast-forward
README.md | 4 ++++
branch.md | 17 +++++++++++++++++
stage.md | 25 +++++++++++++++++++++++++
3 files changed, 46 insertions(+)
create mode 100644 branch.md
create mode 100644 stage.md
Fast-forward
信息,Git告诉我们,这次合并是“快进模式”,也就是直接把master
指向dev
的当前提交,所以合并速度非常快。当然,也不是每次合并都能Fast-forward
$ git branch -d mul
Deleted branch mul (was 8186c3a).
last. 删除后,查看branch
,就只剩下master
分支了
$ git branch
* master