简体   繁体   English

Git 远程跟踪分支和上游分支不同

[英]Git Remote Tracking Branch and Upstream Branch are different

I am not sure how this happened, but if you look at these outputs, emote tracking branch and upstream branch is different.我不确定这是怎么发生的,但是如果您查看这些输出,就会发现表情跟踪分支和上游分支是不同的。 Can somebody explain how could this happen.有人可以解释这怎么会发生。 I know that my pushes are working.我知道我的推动是有效的。 What happens when I pull?当我拉动时会发生什么?

PS C:\DigitalOffers\RegPrice> git branch
* dev
  master

PS C:\DigitalOffers\RegPrice> git branch -vv
* dev    b62f88b [origin/master: ahead 52] Price Zone resolution change.
  master 78d5fb6 [origin/master: behind 37] Merge branch 'master' of https://github.com/xxxxxxxxx

PS C:\DigitalOffers\RegPrice> git log
commit b62f88b137fa067f7d0f75ec35fb8b63fc885f50 (HEAD -> dev, origin/dev)

PS C:\DigitalOffers\RegPrice> cat .git/config
[core]
    symlinks = false
    repositoryformatversion = 0
    filemode = false
    logallrefupdates = true
[remote "origin"]
    url = https://github.com/XXXXXX
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
    rebase = false
[branch "dev"]
    remote = origin
    merge = refs/heads/master
    rebase = false
[branch "origin/dev"]
    remote = origin
    merge = refs/heads/master
    rebase = false
[http "https://github.com"]
    sslVerify = false
[gui]
    wmstate = zoomed
    geometry = 584x210+234+234 469 196

PS C:\DigitalOffers\RegPrice> git push
fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:master

To push to the branch of the same name on the remote, use

    git push origin HEAD

To choose either option permanently, see push.default in 'git help config'.

One more point I want add is- these refs were done by EGit in eclipse.我要补充的一点是 - 这些参考是由 EGit 在 eclipse 中完成的。

A branch whose upstream has a different name is broken.上游具有不同名称的分支已损坏。 That's the situation you are in;这就是你所处的情况; your dev branch has origin's master as its upstream.您的dev分支将 origin 的master作为其上游。 To fix it, repoint the dev branch's upstream so that it is origin's dev instead.要修复它,请重新指向dev分支的上游,以使其成为 origin 的dev

The reason this situation has not destroyed your ability to push is that Eclipse is giving explicit instructions about what to do, ie what branch to push to.这种情况并没有破坏您推送能力的原因是 Eclipse 正在明确指示要做什么,即要推送到哪个分支。 It has been saving you.它一直在拯救你。 But it is better to save yourself by getting the branch's configuration right.但是最好通过正确配置分支来拯救自己。

Fixed the configuration.修正了配置。 Here is the new configuration and new push这里是新配置和新推送

PS C:\DigitalOffers\RegPrice> git branch -vv
* dev    946f432 [origin/dev: ahead 1] Added app description in readme.md
master 78d5fb6 [origin/master: behind 37] Merge branch 'master' of 
https://github.com/XXXXXX

PS C:\DigitalOffers\RegPrice> cat .git/config
[core]
    symlinks = false
    repositoryformatversion = 0
    filemode = false
    logallrefupdates = true
[remote "origin"]
    url = https://github.com/XXXXXXX
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
    rebase = false
[branch "dev"]
    remote = origin
    merge = refs/heads/dev
    rebase = false
[branch "origin/dev"]
    remote = origin
    merge = refs/heads/dev
    rebase = false
[http "https://github.com"]
    sslVerify = false
[gui]
    wmstate = zoomed
    geometry = 584x210+234+234 469 196

PS C:\DigitalOffers\RegPrice> git push
Username for 'https://github.com': 
Password for 'https://@github.com':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 349 bytes | 43.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/XXXXX
    b62f88b..946f432  dev -> dev

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

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