Git - “您的分支比 'origin/master' 领先 3 次提交。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2342618/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git - "Your branch is ahead of 'origin/master' by 3 commits."
提问by Max Williams
Possible Duplicate:
'git pull origin mybranch' leaves local mybranch N commits ahead of origin. Why?
可能的重复:
'git pull origin mybranch' 使本地 mybranch N 提交在原点之前。为什么?
I'm getting this info in git
我在 git 中得到这些信息
>git status
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#
nothing to commit (working directory clean)
And, when i try to push, i get this:
而且,当我尝试推动时,我得到了这个:
fatal: failed to write object
error: unpack failed: unpacker exited with error code
To ssh:<my repository>
! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'ssh:<my repository>'
I've been googling this a bit, (eg there's a stackoverflow question about it here - 'git pull origin mybranch' leaves local mybranch N commits ahead of origin. Why?) and the general advice seems to be to do a pull then a push. But this doesn't work for me - a pull tells me i'm up to date. I've also tried 'git fetch origin' (nothing). I've also tried:
我一直在谷歌上搜索一下,(例如,这里有一个关于它的计算器溢出问题 - 'git pull origin mybranch' 使本地 mybranch N 在原点之前提交。为什么?)并且一般的建议似乎是先拉,然后是推。但这对我不起作用 - 拉动告诉我我是最新的。我也试过'git fetch origin'(什么都没有)。我也试过:
> git remote show origin
* remote origin
URL: ssh://<my repository>
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 (fast forwardable)
In case that helps anyone.
如果这对任何人有帮助。
I also tried adding a dummy file on our web server (which also checks out master), committing it and pushing it up, then pulling it down locally. That all worked fine. But i still can't push. Can anyone tell me what i need to do to resolve this? I don't even really know what it means to say that i've fast forwarded relative to the repository.
我还尝试在我们的 Web 服务器上添加一个虚拟文件(它也检查主服务器),提交它并向上推,然后在本地将其拉下。这一切都很好。但是我还是推不动。谁能告诉我我需要做什么来解决这个问题?我什至不知道说我相对于存储库快进是什么意思。
cheers, max
干杯,最大
EDIT - for ebneter and dan (thanks)
编辑 - 对于 ebneter 和 dan(谢谢)
> git config -l
user.name=Max Williams
push.default=tracking
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=ssh://<my repo url>
branch.master.remote=origin
branch.master.merge=refs/heads/master
A screen grab of gitk is at http://dl.dropbox.com/u/846812/gitk.png
gitk 的屏幕截图位于http://dl.dropbox.com/u/846812/gitk.png
- i'm new to git so i can't interpret this very well, but i'm wondering if the commit done as root (line 6 in the top section), 'merge branch master...' has maybe cocked things up. I don't remember doing a commit as root, puzzled...
- 我是 git 新手,所以我不能很好地解释这一点,但我想知道是否以 root 身份(顶部的第 6 行)提交,“合并分支主...”可能会搞砸。我不记得以 root 身份进行提交,感到困惑......
Dan - I think you're right: the error i get when i try to push is
丹 - 我认为你是对的:我尝试推送时遇到的错误是
error: unable to create temporary sha1 filename ./objects/05: File exists
fatal: failed to write object
error: unpack failed: unpacker exited with error code
EDIT - this comment from the other stackoverflow question i referred to earlier did actually fix it:
编辑 - 我之前提到的另一个 stackoverflow 问题中的这条评论确实修复了它:
git remote alone (showing the right address for GitHub repo) is not enough. To avoid having an "Your branch is ahead" warning message after a git pull, you need first to also define the remote name for a branch. Hence my suggestion: type git config branch.master.remote yourGitHubRepo.git, then try a git pull and a git status and see if the issue remains. – VonC Nov 16 at 20:22
仅使用 git remote(显示 GitHub 存储库的正确地址)是不够的。为了避免在 git pull 之后出现“你的分支在前面”警告消息,你首先需要定义一个分支的远程名称。因此我的建议是:输入 git config branch.master.remote yourGitHubRepo.git,然后尝试 git pull 和 git status 并查看问题是否仍然存在。– VonC 11 月 16 日 20:22
回答by Dan Moulding
It looks like the problem you are having is related to the "unpacker error" mentioned on the "remote rejected" line. For some reason the remote end is failing to unpack the objects that were sent to it. This could be caused by any number of things. Some things you can try:
看起来您遇到的问题与“远程拒绝”行中提到的“解包程序错误”有关。出于某种原因,远程端无法解压缩发送给它的对象。这可能是由许多事情引起的。你可以尝试一些事情:
git fsck --full
Run that locally and at the remote (if possible).
在本地和远程运行(如果可能)。
git repack remotes/origin/master
Run that on the local repo.
在本地存储库上运行它。
If neither of those fixes the problem, try googling git "unpacker error"
for other ideas. I've personally never experienced this problem, so that's unfortunately about all the advice I can give.
如果这些都不能解决问题,请尝试使用谷歌搜索git "unpacker error"
其他想法。我个人从未遇到过这个问题,所以很遗憾,我可以提供所有建议。