【问题标题】:Git - "Your branch is ahead of 'origin/master' by 3 commits." [duplicate]Git - “您的分支比 'origin/master' 领先 3 次提交。” [复制]
【发布时间】:2011-01-21 12:09:20
【问题描述】:

可能重复:
'git pull origin mybranch' leaves local mybranch N commits ahead of origin. Why?

我在 git 中获取此信息

>git status
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#
nothing to commit (working directory clean)

而且,当我尝试推动时,我得到了这个:

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>'

我已经在谷歌上搜索了一下,(例如,这里有一个关于它的 stackoverflow 问题 - 'git pull origin mybranch' leaves local mybranch N commits ahead of origin. Why?),一般建议似乎是先拉然后再推。但这对我不起作用 - 拉动告诉我我是最新的。我也试过'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)

万一这对任何人都有帮助。

我还尝试在我们的网络服务器上添加一个虚拟文件(也检查主文件),提交它并将其向上推送,然后在本地将其拉下。这一切都很好。但是我还是推不开。谁能告诉我我需要做什么来解决这个问题?我什至不知道说我已经相对于存储库快速转发是什么意思。

干杯,最大

编辑 - 为 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

gitk 的屏幕截图位于http://dl.dropbox.com/u/846812/gitk.png

  • 我是 git 新手,所以我不能很好地解释这一点,但我想知道提交是否以 root 身份完成(顶部第 6 行),“合并分支主...”可能已经翘起事情起来了。我不记得以 root 身份提交过,很困惑...

Dan - 我认为你是对的:我尝试推送时遇到的错误是

error: unable to create temporary sha1 filename ./objects/05: File exists

fatal: failed to write object
error: unpack failed: unpacker exited with error code

编辑 - 我之前提到的另一个 stackoverflow 问题的评论确实修复了它:

git remote 单独(显示 GitHub repo 的正确地址)不是 足够的。为了避免在之后出现“您的分支在前面”警告消息 一个 git pull,你首先需要定义一个分支的远程名称。 因此我的建议是:输入 git config branch.master.remote yourGitHubRepo.git,然后尝试 git pull 和 git status 看看是否 问题仍然存在。 – VonC 11 月 16 日 20:22

【问题讨论】:

  • 尝试运行 gitk --all 以查看提交的位置。
  • 您收到的错误通常表明遥控器有问题。但是,您似乎暗示您可以从您的网络服务器推送。那正确吗?你能显示你的配置文件的全部内容吗(git config -l)?
  • 有答案here
  • 感谢您让我再次查看 surya。我在我的帖子中说我已经阅读了该页面,但我没有正确阅读它,因为这个建议修复了它:
    git remote 单独(显示 GitHub repo 的正确地址)是不够的。为避免在 git pull 后出现“您的分支在前面”警告消息,您首先还需要定义分支的远程名称。因此我的建议是:输入 git config branch.master.remote yourGitHubRepo.git,然后尝试 git pull 和 git status 看看问题是否仍然存在。
  • 旧线程,但只是想说明您对另一个线程中评论的引用也对我有用。我做了git config branch.master.remote my_git_repo,它把一切都清理干净了。

标签: git


【解决方案1】:

您遇到的问题似乎与“远程拒绝”行中提到的“解包器错误”有关。由于某种原因,远程端无法解压缩发送给它的对象。这可能是由许多事情引起的。您可以尝试一些事情:

git fsck --full

在本地和远程运行(如果可能)。

git repack remotes/origin/master

在本地 repo 上运行它。

如果这些都不能解决问题,请尝试在 Google 上搜索 git "unpacker error" 以获取其他想法。我个人从未遇到过这个问题,所以很遗憾我能给出的所有建议都是这样。

【讨论】:

    猜你喜欢
    • 2013-04-23
    • 2012-04-27
    • 2022-01-04
    • 1970-01-01
    • 1970-01-01
    • 2012-06-17
    • 2011-01-26
    相关资源
    最近更新 更多