Git - "Your branch is ahead of ' origin/master' 3 次提交。”

标签 git

<分区>

Possible Duplicate:
'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?),一般的建议似乎是先 pull 然后再推。但这对我不起作用 - pull 告诉我我是最新的。我也尝试过“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)

以防对任何人有帮助。

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

干杯,马克斯

编辑 - 对于 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 行),'merge branch master...' 是否已经竖起事情了。我不记得以 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 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 fsck --full

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

git repack remotes/origin/master

在本地仓库上运行它。

如果这些都不能解决问题,请尝试使用谷歌搜索 git "unpacker error"对于其他想法。我个人从未遇到过这个问题,所以不幸的是,这就是我能提供的所有建议。

关于Git - "Your branch is ahead of ' origin/master' 3 次提交。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2342618/

相关文章:

git-remote-https 无法 fork 加载到不同地址的 msys-unistring-2.dll

git - 如何正确管理子目录中被父目录忽略的 git repo 作为自己的项目?

git - 可以提交到存储库的所有可用 Git 特殊文件有哪些?

git - 是否有包含 merge (仅)和非 merge 提交的 `git log` 摘要?

git - 无法在 Git Bash 中输入密码

node.js - 尽管设置了执行权限,OpenShift Node.js 应用程序的操作 Hook 仍不执行

git - 如何从 Git 中的 merge 中排除文件?

git - 由于磁盘空间不足而从失败的 git repack 中恢复

html - 在 git 页面上托管时图像 url 路径混淆的解决方案

Git 仅还原提交中的一些文件