这可以用 Git 实现吗?
我希望我的 git 存储库处于特定提交时的状态。一旦仓库处于该状态,我希望能够推送到 Github,使远程处于该状态。我知道我可以调用 git checkout
我猜我应该用 git checkout 做一些事情,但我不知道该怎么做。
感谢您对这个简单问题的任何帮助:)
I want my git repo to be at the state it was at a specific commit. Once the repo is at the state, I want to be able to push to Github, making the remote be at that state. I know I can call git checkout <commit hash>
and my local repo will be at the state it was at the given commit, but it won't let you push.
I'm guessing that I should do something with git checkout
but I don't know what to do.
Thanks for any help on this simple question :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你需要用武力推动,因为你会失去历史。
这将有力地推动你的改变。如果您尝试撤消某些操作,您可能需要考虑 git revert,因为它允许您保留历史记录。
You need to push with force since you are going to lose history.
This will forcefully push your changes. If you are trying to undo something, you may want to consider
git revert
since it will allow you to keep history.使用 git reset --hard将存储库重置为特定提交。
这将使您丢失工作目录更改以及
提交
之后的任何提交。您仍然可以从 git reflog 取回较新的提交,然后对这些提交使用 git reset 。另外,如果您已经推送了其他提交,则必须避免在没有它们的情况下推送到远程。
Use
git reset --hard <commit>
to reset the repo to a particular commit.This will make you lose your working directory changes and any commit after the
commit
. You can still get back the newer commits fromgit reflog
and then usinggit reset
on those commits.Also, if you had already pushed the other commits, you must avoid pushing to the remote without them.