`git checkout -b new-feature master`做什么?

时间:2017-03-21 23:05:34

标签: git git-merge

我跟着这个tutorial,我对快进合并示例感到困惑,它执行以下操作:

# Start a new feature
git checkout -b new-feature master
# Edit some files
git add <file>
git commit -m "Start a feature"
# Edit some files
git add <file>
git commit -m "Finish a feature"
# Merge in the new-feature branch
git checkout master
git merge new-feature
git branch -d new-feature

第二行有什么作用?它与git checkout -b new-feature有什么不同?

1 个答案:

答案 0 :(得分:1)

命令

git checkout -b new-feature master

将从new-feature master 创建一个名为master的新分支,也会检出该新分支。

查看documentation以获取更多信息:

git checkout -b|-B <new_branch> [<start point>]

如果省略<start point>,则将当前分支用作起点。