有人推了一个分行testgit push origin test共享仓库的共享仓库。git branch -r如何查看遥控器test我试过了

  • git checkout test,它没有做任何事情
  • git checkout origin/test给给* (no branch)

当前回答

你基本上看到了树枝,但你还没有本地的拷贝!

你需要,你需要fetch分支...

您可以简单地获取并退出分支, 使用下面的一条线命令来做到这一点 :

git fetch && git checkout test

我还创建了下面的图像 让你分享差异,看看如何fetch以及它是如何与pull:

git fetch

其他回答

首先,你需要做的是:

git fetch如果你不知道 分支名称

git fetch origin branch_name

第二,您可通过下列方式检查远程分支进入本地 :

git checkout -b branch_name origin/branch_name

-b将从您选中的远程分支中以指定的名称创建新分支 。

使用 :

git checkout -b <BRANCH-NAME> <REMOTE-NAME>/<BRANCH-NAME>

其它答案在我的良性案例中不适用于现代 Git 。 如果远程分支是新的, 您可能需要先拉一下, 但我还没有检查过这个案例 。

要克隆 Git 仓库, 需要 :

git clone <either ssh url /http url>

上述命令检查了所有分支,但只检查了master将初始化分支。 如果您想要检查其它分支, 请做 :

git checkout -t origin/future_branch (for example)

此命令检查远程分支, 您的本地分支名称将与远程分支相同 。

如果您想要在检查退出时覆盖您的本地分支名称 :

git checkout -t -b enhancement origin/future_branch

现在您的本地分支名称是enhancement,但您的远程分支名称是future_branch.

我被困在一个状况中看到error: pathspec 'desired-branch' did not match any file(s) known to git.以上所有建议。我正在讨论Git 1.8.3.1版本。

所以这个为我工作:

git fetch origin desired-branch
git checkout -b desired-branch FETCH_HEAD

背后的解释是,我注意到 当我拿起遥控树枝时,时前:

git fetch origin desired-branch

From github.com:MYTEAM/my-repo
    * branch            desired-branch -> FETCH_HEAD

缩略git remote show <origin name>命令将列出所有分支(包括未跟踪的分支)。然后您可以找到要获取的远程分支名称。

示例:

git remote show origin

使用这些步骤获取远程分支 :

git fetch <origin name> <remote branch name>:<local branch name>
git checkout <local branch name > (local branch name should the name that you given fetching)

示例:

git fetch origin test:test
git checkout test