为什么它说“你的分支在857次提交之前在原点/主设备之前”当我需要*拉*起源的主人 [英] why does it say "Your branch is ahead of origin/master by 857 commits" when I need to *pull* origin master

查看:93
本文介绍了为什么它说“你的分支在857次提交之前在原点/主设备之前”当我需要*拉*起源的主人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我知道一些类似的措词问题,例如:


没有一个(AFAICT)的答案与我的这个问题的版本相符。



我的情况是:

  $ git status 
#分支稳定
没有提交(工作目录清理)
$ git checkout master
转换到分支'master'
您的分支在857次提交之前超过'origin / master'。

在现有的问题中,接受和回答的答案大多同意这意味着它的字面意思是......我在前面,我需要将我的新提交推送到origin / master。



我知道实际上情况正好相反,我的本地 master 分支位于远程 origin / master 后面,实际上我需要 git pull在本地进行一些工作之前,请使用原始大师。 (或可能只是 git fetch origin ?)



我的问题是...是否有某些原因的措辞您的分支在857次提交之前领先于origin / master,这样它的字面意思就变得有意义了

<因为我目前的理解方式是,意思与消息所说的相反('我的分店'在原产地/主人后面')。



或者是否真的意味着:远程主分支的头部在本地原点/主跟踪分支之前??

更新
FWIW我正在一个由其他六个开发人员组成的团队中工作。我们每天都会毫无问题地多次拉,推,推等。我在这里没有错误......我只是想了解为什么Git以这种方式说出它的消息 - 无论是措辞本身是否被严重选择,或者是否有一些Git的基本概念导致他们这样说话而且我不能正确理解。



更多信息

这里是我猜想可能是相关部分输出来自 git config -l <​​/ code>

  remote.origin.fetch = + refs / heads / *:refs / remotes / origin / * 
remote.origin.url = https://code.google.com/a/google.com/p/xxxxx/
分支。 master.remote = origin
branch.master.merge = refs / heads / master
branch.master.mergeoptions = - no-ff


解决方案

你正在想这个。该消息并不是说遥控器在后面。它说你的本地存储库记录的提交'origin / master'是。在生成该消息的过程中,git并没有与远程进行通信。它只是查看.git目录,并返回了 .git / refs / remotes / origin / master 的内容。亲自尝试一下。这两个命令应该从存储库的顶层返回相同的东西:

  cat .git / refs / remotes /第二个命令就是简单的一个管道工程师,一个管理员,一个管理员,一个管理员,一个管理员,一个管理员,一个管理员,一个管理员,一个管理员,一个管理员,命令来查找原点/主指针。您可以用任何分支替换'origin / master'以获得该分支上最近的提交。



该消息告诉您,您的本地主在前面由'git rev-parse origin / master'由857提交返回的提交。这种情况是怎么发生的?我不能确切地说,但是我会在你意外地将一个不同的分支合并到'主'中时花费相当多的钱。每当我看到这个问题,这是一个从用户错误合并。



首先,发出 git fetch origin 确保'起始/主'指针是最新的。然后,研究你的 git log 。寻找最近你不期望的事情。下载 tig程序或使用 gitk 来获取你的提交历史。这是一个很好的选择,你在'master'签出时意外地发出了 git pull stable 。或类似的东西。


Firstly, I'm aware of a number of similarly worded questions, eg:

None of them (AFAICT) has an answer that matches my version of this question.

My situation is:

$ git status
# On branch stable
nothing to commit (working directory clean)
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 857 commits.

In the existing questions the accepted and upvoted answers mostly concur that it means literally what it says... I'm ahead and I need to push my new commits to origin/master.

I know that actually the opposite situation is true, that my local master branch is behind the remote origin/master and actually I need to git pull origin master before doing some work on it locally. (or possibly just git fetch origin ?)

My question is... is there some reason for the message to be worded Your branch is ahead of 'origin/master' by 857 commits. such that it literally makes sense?

Because the way I understand it at the moment the meaning is the opposite of what the message says ('my branch' is behind origin/master).

Or does it really mean: "The HEAD of the remote master branch is ahead of your local origin/master tracking branch" ?

update FWIW I am working in a team of half a dozen other developers. We all pull, commit and push etc many times a day without problem. I don't have a bug here... I'm just trying to understand why Git words its message this way - whether the wording itself is badly chosen, or if there's some underlying concept of Git that causes them to word it this way and which I'm not understanding properly.

more info
here is what I guess may be the relevant part of output from git config -l

remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=https://code.google.com/a/google.com/p/xxxxx/
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.master.mergeoptions=--no-ff

解决方案

You are over thinking this. The message isn't saying the remote is behind. It's saying your local repository's recorded commit for 'origin/master' is. At no point in generating that message did git communicate with a remote. It simply looked into the .git directory, and returned the contents of .git/refs/remotes/origin/master. Try it yourself. Both of these commands should return the same thing from the top-level of the repository:

cat .git/refs/remotes/origin/master
git rev-parse origin/master

The second command is simply a plumbing command for finding the 'origin/master' pointer. You could replace 'origin/master' with any branch to get the most recent commit on that branch.

That message is telling you is that your local 'master' is ahead of the commit returned by 'git rev-parse origin/master' by 857 commits. How did this situation arise? I can't say exactly, but I'd put considerable money on you accidentally merging a different branch into 'master'. Every time I've seen this problem, it's a bad merge from user error.

First, issue git fetch origin to make sure that 'origin/master' pointer is up-to-date. Then, study your git log. Look for something recent you don't expect. Download a program like tig or use gitk to get a visual graph of your commit history. It's a good bet you accidentally issued git pull stable while checked out on 'master'. Or something similar.

这篇关于为什么它说“你的分支在857次提交之前在原点/主设备之前”当我需要*拉*起源的主人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆