繁体   English   中英

为什么我在远程git存储库上有多个跟踪分支?

[英]Why do I have multiple tracking branches on a remote git repository?

我将要对前一段时间为github项目制作的fork进行更新。 当我尝试查看远程存储库时,看到了以下内容:

me@Bedrock:~/Downloads/git_proj/git_proj$ git remote show origin
* remote origin
  Fetch URL: https://github.com/jsmith/git_proj.git
  Push  URL: https://github.com/jsmith/git_proj.git
  HEAD branch: master
  Remote branches:
     api-consistency               new (next fetch will store in remotes/origin)
     gp-1                          tracked
     gp-2                          new (next fetch will store in remotes/origin)
     master                        tracked
     refs/remotes/origin/new_conv_ops stale (use 'git remote prune' to remove)
     revert-6817-getfullargspec    new (next fetch will store in remotes/origin)
     tf-gp                         new (next fetch will store in remotes/origin)
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (local out of date)

我不明白为什么显示多个分支被跟踪。 我不应该只跟踪master分支吗? 如果是这样,为什么gp-1分支显示为被跟踪? 这是否意味着我可以跟踪该分支?

我是否相信我的本地master分支会从远程master分支进行推/拉,这是正确的,但是如果我愿意,我可以让其他本地分支从任意远程分支进行推/拉吗?

有关使用遥控器的Git文档很好地说明了您的输出。 要在此处重复输出:

HEAD branch: master
Remote branches:
   api-consistency               new (next fetch will store in remotes/origin)
   gp-1                          tracked
   gp-2                          new (next fetch will store in remotes/origin)
   master                        tracked
   refs/remotes/origin/new_conv_ops stale (use 'git remote prune' to remove)
   revert-6817-getfullargspec    new (next fetch will store in remotes/origin)
   tf-gp                         new (next fetch will store in remotes/origin)

标记为已tracked分支,例如gp-1 ,是存在于远程站点上并且已经在本地拉出的那些分支。 另一方面,标记为new分支意味着它们存在于远程服务器上,但您尚未在本地拥有它们。

同样,HEAD分支被标记为master意味着master是某些操作(例如git pull )的默认分支。 如果您在本地发出git pull ,但未明确指定要合并的分支,则将使用master

您是分支master 您所有的推拉操作都将master 删除不需要的分支:

git branch -d <branch name>

要远程删除它们,请使用:

git push origin --delete <branch name>

要更改任何分支从何处推/拉,请使用:

git branch --set-upstream <your_local_branch> <your_new_remote/branch_name>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM