git 创建新分支 默认是以当前分支为基准
如果想以指定分支为基准,只要在最后加上分支名即可
git branch [new_branch_name] [old_branch_name]
#或者
git checkout -b [new_branch_name] [old_branch_name]
#对于远程分支也可以用(上面两个应该在已经fetch 过的情况下用):
git fetch origin [remote_branch]:[local_branch_name]
比如
git branch new_feature origin/master
git checkout -b new_feature origin/master
git fetch origin master:new_feature
参考:https://stackoverflow.com/questions/1783405/how-do-i-check-out-a-remote-git-branch
本文介绍如何使用Git创建新分支,并提供了以指定分支为基准创建新分支的方法。包括使用`git branch`和`git checkout -b`命令的具体语法,以及如何从远程分支创建本地分支。
4万+

被折叠的 条评论
为什么被折叠?



