如何更新我的提交?

huangapple go评论75阅读模式
英文:

Beginner Question: How can I update my commits?

问题

在我的GitBash中,我编辑了提交,直到只剩下四个。

如何更新我的提交?

这是因为我想要更新网站上的内容,并删除那另外两个关于我的文件。

如何更新我的提交?

我尝试直接推送它,但它显示了这个消息。

如何更新我的提交?

有没有快速的方法来做这个?

英文:

In my GitBash, I edited the commits until there's only four left.

如何更新我的提交?

That is because I want to like update what's on our website and get rid of those other two about me files.

如何更新我的提交?

I tried to directly push it, but it it says this.

如何更新我的提交?

Is there a quick way to do it?

答案1

得分: 1

由于您有效地重写了历史记录,Git 将不允许您简单地推送新的真相。您将需要执行所谓的 "强制推送",在这里有描述:https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-force-with-lease。

请注意,git push --force-with-lease origin master 意味着所有检查都被跳过,因此您可能会丢失提交。但在这种情况下,似乎这就是您打算做的事情(删除一些提交),所以没问题。

请确保您多次仔细确认您要推送的内容是确切的。如果您没有该存储库的备份副本,那么恢复可能会变得棘手。

此外,不要在每次推送时都使用 --force-with-lease,只有在真正需要时才使用。

英文:

Since you effectively rewrote history, git will not allow you to simply push the new truth. You will need what is called a "force push", described here: https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-force-with-lease.

Please note that git push --force-with-lease origin master means all checks are skipped, and you may therefor lose commits. In this case though, that seems to be what you are intending to do (removing a few commits) so it's OK.

Please make double and triple sure that you're pushing exactly what you want to push. If you don't have a copy of the repository elsewhere, then this might be a tricky thing to revert.

Also, do not use --force-with-lease with every push, only when you really need to.

huangapple
  • 本文由 发表于 2023年8月9日 16:19:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76865842-2.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定