下面哪一行是正确的?
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'
它们之间的区别是什么?
当前回答
切换到git中的另一个分支。直截了当的回答,
git-checkout -切换分支或恢复工作树文件
git fetch origin <----this will fetch the branch
git checkout branch_name <--- Switching the branch
在切换分支之前,确保您没有任何修改过的文件,在这种情况下,您可以提交更改或保存它。
其他回答
以下是我遵循的步骤:
Git克隆{link} CD(回收文件夹)
你可以检查状态和你正在使用的分支:
git状态 git分支 Git分支-a
注意:在这里,如果您在迁移到新分支之前对本地回购进行了更改,那么以下步骤仍然有效。
如果“git branch”显示master,你想创建+移动到另一个分支:
Git checkout -b{分支名称}
使用“git branch”再次检查分支 它现在应该显示您在新的分支中。
现在添加、提交和推送:
Git添加。 Git commit -m "添加新分支" Git推送源{分支名称}
上述步骤适用于我在移动到新的本地分支之前进行更改或移动到新分支之后进行更改的情况。 我希望它能帮助遇到类似情况的人,这也是这里提到的问题的解决方案:链接
切换到git中的另一个分支。直截了当的回答,
git-checkout -切换分支或恢复工作树文件
git fetch origin <----this will fetch the branch
git checkout branch_name <--- Switching the branch
在切换分支之前,确保您没有任何修改过的文件,在这种情况下,您可以提交更改或保存它。
切换到git中的另一个分支可以用一个命令完成。
Git开关branch-name
我用这个来切换一个分支到另一个你可以使用它为我工作的魅力。
git开关[branch]或 git结帐[branch]
示例:git switch develop OR Git检查开发
[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']