下面哪一行是正确的?

git checkout 'another_branch'

or

git checkout origin 'another_branch'

or

git checkout origin/'another_branch'

它们之间的区别是什么?


当前回答

日常工作中有用的命令:

git checkout -b "branchname" ->  creates new branch
git branch                   ->  lists all branches
git checkout "branchname"    ->  switches to your branch
git push origin "branchname" ->  Pushes to your branch
git add */filename           -> Stages *(All files) or by given file name
git commit -m "commit message" -> Commits staged files
git push                     -> Pushes to your current branch

如果你想从特性分支合并到开发, 首先使用命令“git branch dev/develop”检查dev分支 然后输入合并命令"git merge featurebranchname"

其他回答

检查:git分支-a

如果你只得到一个分支。然后执行以下步骤。

步骤1:git配置——list 步骤2:git配置——unset remote.origin.fetch 步骤3:git配置——添加remote.origin.fetch +refs/heads/*:refs/remotes/origin/*

对我有效的方法如下:

切换到所需的分支:

git checkout -b BranchName

然后我把"大师"拉过来

git pull origin master

[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']

在Git 2.23以后,可以使用Git switch <分支名称>来切换分支。

日常工作中有用的命令:

git checkout -b "branchname" ->  creates new branch
git branch                   ->  lists all branches
git checkout "branchname"    ->  switches to your branch
git push origin "branchname" ->  Pushes to your branch
git add */filename           -> Stages *(All files) or by given file name
git commit -m "commit message" -> Commits staged files
git push                     -> Pushes to your current branch

如果你想从特性分支合并到开发, 首先使用命令“git branch dev/develop”检查dev分支 然后输入合并命令"git merge featurebranchname"