git:为什么在我执行“git Push”后,我的提交次数领先于 origin/master?
我在服务器上使用裸 git 存储库进行备份,并在本地执行“git commit”后使用“git Push”将本地更改推送到那里。
“git status”告诉我
# On branch master
# Your branch is ahead of 'origin/master' by X commits.
如果我修改一个文件,然后进行另一次提交,然后进行推送,git 会告诉我我的分支领先 X+1 次提交。 'git remote show origin' 显示 fetch 和 pull URL 与我作为推送参数提供的相同。
我已经验证我的更改确实被推送到服务器存储库(通过拉入不同的位置并检查内容)。
我在这里做错了什么?
PS:我知道这里有几个相关的问题,但我无法在其中任何一个中找到我的具体问题的答案。如果我在这方面错了,请指出正确的方向。
I am using a bare git repository on a server for backup, and push local changes there with 'git push' after doing 'git commit' locally.
'git status' tells me
# On branch master
# Your branch is ahead of 'origin/master' by X commits.
If I modify a file, and then do another commit followed by a push, git tells me that my branch is ahead by X+1 commits. 'git remote show origin' shows me that both fetch and pull URLs are the same as I supply as argument to push.
I have verified that my changes do indeed get pushed to the server repository (by pulling into a different location and checking the contents).
What am I doing wrong here?
PS: I am aware that there are several related questions here on SO, but I could not find the answer to my specific issue in any of those. Please point me in the right direction if I'm wrong in that regard.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来您正在直接推送到 URL。尝试 git push origin,这将更新
origin
的引用(原则上,您可以使用相同的引用名称两次使用相同的 URL:消息引用引用名称)。It sounds like you're pushing to the URL directly. Try
git push origin
, this will update the references fororigin
(in principle, you can have the same URLs twice with the same reference name: the message refers to the reference name).有时,即使您实际上没有本地提交,您也会遇到这种情况。如果你陷入困境,并且 a
不能帮助你,只需尝试
这些命令应该可以直接设置你的存储库,并解决你在 origin/master 之前通过 X 次提交的问题。
Sometimes you'll run into this even though you actually don't have local commits. If you're stuck, and a
doesn't help you out, simply try
These commands should set your repo straight and clear up your issue of being ahead of origin/master by X commits.
我发现更新您的“来源”跟踪信息也有效。
尝试:
I've found that updating your tracking information of "origin" works as well.
Try: