【问题标题】:`Local ref configured for 'git push':` section of `git remote show origin` is not updating为“git push”配置的“本地参考”:“git remote show origin”部分未更新
【发布时间】:2017-11-13 01:26:43
【问题描述】:

我在本地有一个分支sf,在远程有一个分支serverfix

git remote show origin的输出:

* remote origin
  Fetch URL: git@github.com:pr0g4amtest1ng/git-remote.git
  Push  URL: git@github.com:pr0g4amtest1ng/git-remote.git
  HEAD branch: master
  Remote branches:
    master    tracked
    serverfix tracked
  Local branches configured for 'git pull':
    master merges with remote master
    sf     merges with remote serverfix
  Local ref configured for 'git push':
    master pushes to master (up to date)

为了方便git push,我做了以下事情:

git config push.default upstream
git push -u

现在如果我再次运行git remote show origin

* remote origin
  Fetch URL: git@github.com:pr0g4amtest1ng/git-remote.git
  Push  URL: git@github.com:pr0g4amtest1ng/git-remote.git
  HEAD branch: master
  Remote branches:
    master    tracked
    serverfix tracked
  Local branches configured for 'git pull':
    master merges with remote master
    sf     merges with remote serverfix
  Local ref configured for 'git push':
    master pushes to master (up to date)

奇怪的是为“git push”配置的本地参考:根本没有改变。 它不应该添加一个像sf pushes to serverfix (up to date) 这样的条目吗?

但是如果我执行git push origin sf,它会给出Everything up-to-date,并且它不再在远程创建sf 分支,这意味着它正在跟踪。

我如何知道正在跟踪哪个分支以进行 'git push' ? 为什么没有为 为 'git push' 配置的本地参考添加条目: 或者何时为此添加条目。

【问题讨论】:

    标签: git github


    【解决方案1】:

    你有两个选择

    • 第一选择:

      git config remote.origin.push <local_branch_refs>:<remote_branch_refs>

    • 第二个选择: git config --edit 编辑 .git/config 文件。

      [远程“原点”]
      推=<local_branch_refs>:<remote_branch_refs>


    对于你的情况,应该是:

    git config remote.origin.push refs/heads/sf:/refs/heads/serverfix
    

    之后,您可以在git remote show originLocal ref configured for 'git push'部分看到更新。

    【讨论】:

      【解决方案2】:

      push.default = 上游:推送当前分支

      列出分支及其上游:git branch -vv

      【讨论】:

      • 那么git remote show origin 中的Local ref configured for 'git push': 部分呢?如果push.default upstream 是你所说的,那么push.default matching 呢?
      • 关于git branch -vv,它没有显示关于git push的跟踪信息,而是显示git fetch的跟踪信息
      • 匹配 - 推送所有分支两端具有相同名称。默认情况下,git fetch 配置为从与git push 相同的远程获取相同的分支。
      • 你的意思是upstreammatching 都将负责同名的分支?
      • (我更新了我的答案。)使用push.default = upstream,您可以一一推送分支。使用matching,您可以推送许多但只能推送到具有相同名称的分支。要将多个分支推送到具有不同名称的远程分支,您应该仔细配置 .git/config 中的分支。请参阅stackoverflow.com/q/7583091/7976758 并点击那里的链接。
      猜你喜欢
      • 2023-03-30
      • 2015-01-20
      • 2015-10-03
      • 1970-01-01
      • 2018-03-04
      • 1970-01-01
      • 2021-04-13
      • 1970-01-01
      • 2018-10-05
      相关资源
      最近更新 更多