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

  • git checkout test,它没有做任何事情
  • git checkout origin/test给给* (no 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

其他回答

有许多替代办法,例如:

  • 备选案文1:

    git fetch && git checkout test
    

    这是最简单的办法

  • 备选案文2:

    git fetch
    git checkout test
    

    是一样的,但分两步走

git fetch --all

将所有远程分支都带回您的本地

git checkout test

将您切换到测试分支

工作命令

  1. git fetch origin 'remote_branch':'local_branch_name'

  2. git switch 'local_branch_name'

  3. git pull origin 'remote_branch':'local_branch_name'

第一个是从远程分支获取分支和创建本地分支。

第二个是转换到当地分行。

第三是将最近的远距离变化推到当地分部。

缩略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

我被困在一个状况中看到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