git:为什么在我执行“git Push”后,我的提交次数领先于 origin/master?

发布于 2024-09-26 19:43:24 字数 452 浏览 6 评论 0原文

我在服务器上使用裸 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撧情箌佬 2024-10-03 19:43:24

听起来您正在直接推送到 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 for origin (in principle, you can have the same URLs twice with the same reference name: the message refers to the reference name).

如梦初醒的夏天 2024-10-03 19:43:24

有时,即使您实际上没有本地提交,您也会遇到这种情况。如果你陷入困境,并且 a

git pull origin [branch]

不能帮助你,只需尝试

git pull origin and git pull

这些命令应该可以直接设置你的存储库,并解决你在 origin/master 之前通过 X 次提交的问题。

Sometimes you'll run into this even though you actually don't have local commits. If you're stuck, and a

git pull origin [branch]

doesn't help you out, simply try

git pull origin and git pull

These commands should set your repo straight and clear up your issue of being ahead of origin/master by X commits.

じ违心 2024-10-03 19:43:24

我发现更新您的“来源”跟踪信息也有效。

尝试:

git fetch origin

I've found that updating your tracking information of "origin" works as well.

Try:

git fetch origin
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文