git 在 git 提取后如何进行结帐
How does git checkout work after git fetch
我刚刚做了
git fetch origin <remoteBranch>
然后我就做了
git checkout <remoteBranch>
这创建了一个名为 <remoteBranch>
的本地分支。
它是如何工作的?通常当我想创建一个本地分支时,我必须做
git checkout -b
据我所知,当您要求结帐时,如果该分支在本地不存在,git 将尝试查找一个(且仅一个)具有该名称的远程分支。如果它存在并且只有一个(在你的回购协议上可能设置了多个具有相同分支名称的远程)然后 git 猜测这就是你想要的分支,所以它使用远程分支作为上游在本地创建它分支.
git checkout <branch>
[...]If <branch>
is not found but there does exist a tracking branch in exactly one remote (call it <remote>
) with a matching name, treat as equivalent to
$ git checkout -b <branch> --track <remote>/<branch>
If the branch exists in multiple remotes and one of them is named by the checkout.defaultRemote configuration variable, we’ll use that one for the purposes of disambiguation, even if the <branch>
isn’t unique across all remotes. Set it to e.g. checkout.defaultRemote=origin to always checkout remote branches from there if <branch>
is ambiguous but exists on the origin remote. See also checkout.defaultRemote in git-config[1].
我刚刚做了
git fetch origin <remoteBranch>
然后我就做了
git checkout <remoteBranch>
这创建了一个名为 <remoteBranch>
的本地分支。
它是如何工作的?通常当我想创建一个本地分支时,我必须做
git checkout -b
据我所知,当您要求结帐时,如果该分支在本地不存在,git 将尝试查找一个(且仅一个)具有该名称的远程分支。如果它存在并且只有一个(在你的回购协议上可能设置了多个具有相同分支名称的远程)然后 git 猜测这就是你想要的分支,所以它使用远程分支作为上游在本地创建它分支.
git checkout <branch>
[...]If
<branch>
is not found but there does exist a tracking branch in exactly one remote (call it<remote>
) with a matching name, treat as equivalent to$ git checkout -b <branch> --track <remote>/<branch>
If the branch exists in multiple remotes and one of them is named by the checkout.defaultRemote configuration variable, we’ll use that one for the purposes of disambiguation, even if the
<branch>
isn’t unique across all remotes. Set it to e.g. checkout.defaultRemote=origin to always checkout remote branches from there if<branch>
is ambiguous but exists on the origin remote. See also checkout.defaultRemote in git-config[1].