【发布时间】: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