我刚刚使用命令
创建了之前提交的分支git branch thenewbranch 03771674c482e4611cc48ee120a16a91dfb2793d
现在我想通过
签出要在Eclipse中使用的分支$ git checkout -b thenewbranch
但我收到了这个错误
fatal: A branch named 'thenewbranch' already exists.
答案 0 :(得分:4)
git checkout -b thenewbranch
意味着创建一个名为“thenewbranch”的新分支,然后进入它
你只需要
git checkout thenewbranch
git checkout -b | -B []指定-b导致a 要创建新分支,就像调用git-branch [1]一样 检查过了。在这种情况下,您可以使用--track或--no-track 选项,将传递给git分支。为方便起见, - 跟踪 没有-b意味着分支创建;请参阅--track的说明 下方。
如果给出了-B,如果它不存在则被创建; 否则,它被重置。这是
的交易等价物
答案 1 :(得分:1)
您无需指定-b
。
简单地:
git branch thenewbranch 03771674c4
git checkout thenewbranch
-b
选项是一种不同的行为,这意味着您实际上想要从当前thenewbranch
(隐式)创建一个名为HEAD
的新分支。