理解“git remote show”命令输出......这意味着:“为'git push'配置了本地引用”?

时间:2017-08-30 12:39:44

标签: git github git-branch

我有两个遥控器和两个本地分支机构:

  • 本地分支“master”正在跟踪远程分支“origin / master”
  • 本地分支“镜像”正在跟踪远程分支“github / master”

这是在我的.git / config文件中:

...

[remote "origin"]
    url = http://my.gitlab.com/nandoquintana/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[remote "github"]
    url = https://github.com/nandoquintana/repo.git
    fetch = +refs/heads/*:refs/remotes/github/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[branch "mirror"]
    remote = github
    merge = refs/heads/master
[push]
    default = tracking

这是“git remote show origin”的输出:

$ git remote show origin 

* remote origin
  Fetch URL: http://my.gitlab.com/nandoquintana/repo.git
  Push  URL: http://my.gitlab.com/nandoquintana/repo.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

$ git remote show github

* remote github
  Fetch URL: https://github.com/nandoquintana/repo.git
  Push  URL: https://github.com/nandoquintana/repo.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local branch configured for 'git pull':
    mirror merges with remote master
  Local ref configured for 'git push':
    master pushes to master (local out of date)

“推”和“拉”命令都能正常工作:

  • “push”命令将本地分支中的已提交编辑发送到“她的”远程分支。
  • “pull”命令将从远程分支的提交带到“她的”本地分支。

那么,为什么“本地参考配置为'git push'”是“主人推动掌握”?为什么不“镜子推动掌握”?什么“本地过时”是什么意思?

@torek回答后

更新

这里我们有一些参考:

$ git ls-remote github
455063a9db09977535ac808af5729181b153f4c7    HEAD
455063a9db09977535ac808af5729181b153f4c7    refs/heads/master

$ cat .git/refs/heads/master
ca9e4399058a4998bd7c993f86d6740cfaec820b
$ cat .git/refs/heads/mirror
455063a9db09977535ac808af5729181b153f4c7
$ cat .git/refs/remotes/github/master
455063a9db09977535ac808af5729181b153f4c7

确实,“refs / remotes / github / master”和“refs / heads / master”不相等。这就是“本地过时”消息出现的原因:

master pushes to master (local out of date)

对我来说这不是问题,我肯定知道“remotes / github / master”和本地“master”中的代码是不同的。

尽管如此,“remotes / github / master”和本地“镜像”中的代码是相同的。事实上,refs“refs / remotes / github / master”和“refs / heads / mirror”是相同的。

这是让我安心的信息:

mirror pushes to master (up to date)

我如何配置remote / github ...或push.default ...来获得此输出?

0 个答案:

没有答案