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

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

当前回答

命令

git fetch --all
git checkout -b <ur_new_local_branch_name> origin/<Remote_Branch_Name>

等于

 git fetch --all

时和时

 git checkout -b fixes_for_dev origin/development

两者将创造latest fixes_for_dev调自development

其他回答

接受接受的答复不为你工作?

虽然第一个和选定的答案是技术上的正确中,您可能尚未从远程仓库中检索到所有对象和参考文献。如果是这种情况,您将会收到以下错误:

$ git checkout -b remote_branch origin/remote_branch

致命: git 检出: 更新路径与切换分支不兼容 。
您是否打算检查“ 来源/ remote_ branch ” 无法以承诺方式解决的“ 来源/ 远程- branch ” ?

解决方案

如果您收到此消息, 您必须首先完成git fetch origin何 地origin是运行前的远程仓库的名称git checkout remote_branch。以下是答复的完整例子:

$ git fetch origin
remote: Counting objects: 140, done.
remote: Compressing objects: 100% (30/30), done.
remote: Total 69 (delta 36), reused 66 (delta 33)
Unpacking objects: 100% (69/69), done.
From https://github.com/githubuser/repo-name
   e6ef1e0..5029161  develop    -> origin/develop
 * [new branch]      demo       -> origin/demo
   d80f8d7..359eab0  master     -> origin/master

$ git checkout demo
Branch demo set up to track remote branch demo from origin.
Switched to a new branch 'demo'

如你所见 跑着跑着git fetch origin检索到我们尚未安装的远程分支, 以跟踪本地机器 。 从那里, 因为我们现在有一个 ref 到远程分支, 我们就可以运行git checkout remote_branch我们会从远程追踪中受益

这将DWIM DEWIM DEWIM DEWIM DEWIM DEWIM DEWIM DEWIM DEWIM DEWIM DIWIM DEWIM DIWIM DIWWM DI DIWIM DI DIWIM DI DIWIM DI DIWM DIWIM DI DIWM DI DI DIWIM DI DI DIWM远程未命名来源( 用于远程未命名来源) 。文档文件文件):

$ git checkout -t remote_name/remote_branch

要添加一个新的远程, 您需要首先做以下操作 :

$ git remote add remote_name location_of_remote
$ git fetch remote_name

第一个告诉Git 遥控器存在, 第二个得到承诺。

命令

git fetch --all
git checkout -b <ur_new_local_branch_name> origin/<Remote_Branch_Name>

等于

 git fetch --all

时和时

 git checkout -b fixes_for_dev origin/development

两者将创造latest fixes_for_dev调自development

要克隆 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.

使用 :

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

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