下面哪一行是正确的?
git checkout 'another_branch'
or
git checkout origin 'another_branch'
or
git checkout origin/'another_branch'
它们之间的区别是什么?
下面哪一行是正确的?
git checkout 'another_branch'
or
git checkout origin 'another_branch'
or
git checkout origin/'another_branch'
它们之间的区别是什么?
当前回答
如果你想让分支跟踪远程分支,如果你要向分支提交更改和拉取更改等,这是非常重要的,你需要为实际的签出添加一个-t,如下所示: Git checkout -t branchname
其他回答
在Git 2.23以后,可以使用Git switch <分支名称>来切换分支。
我用这个来切换一个分支到另一个你可以使用它为我工作的魅力。
git开关[branch]或 git结帐[branch]
示例:git switch develop OR Git检查开发
要切换到一个分支与你的改变,你应该先做一个取回。这是为了像您的包一样保存更改。Json或。env文件
所以: git获取
然后: Git checkout <新分支>
这个答案是给那些被困住一段时间的人的,比如我。
[git checkout "branch_name"]
是另一种说法:
[git checkout -b branch_name origin/branch_name]
以防“branch_name”仅在远程存在。
[git checkout -b branch_name origin/branch_name]在你有多个遥控器的情况下很有用。
关于[git checkout origin 'another_branch'],我不确定这是可能的,AFAK你可以使用“fetch”命令来做到这一点 ——[git获取来源'another_branch']
如果你想让分支跟踪远程分支,如果你要向分支提交更改和拉取更改等,这是非常重要的,你需要为实际的签出添加一个-t,如下所示: Git checkout -t branchname