Git:使用恢复或检出来撤消推送的更改?(Git: use revert or checkout to undo pushed changes?)

编程入门 行业动态 更新时间:2024-10-19 12:44:47
Git:使用恢复或检出来撤消推送的更改?(Git: use revert or checkout to undo pushed changes?)

Git是一个惊人的工具,但我还没有想到解决推送的更改的最佳方法。 这是情况。

我在一个分支上,并推动了几次提交给GitHub。 从那时起,我们已经决定,我已经放弃了兔子洞,我们需要取消我已经完成的一些提交,并重新开始。 从本质上讲,我需要将所有推送的提交反转回前一个提交。 以下是我认为合适的两个命令

git revert # - creates a new commit that "undoes" the changes of one specific commit git checkout 'commit SHA' # - sets the head to that specific commit, wherein I will re-push to the repo, undoing my changes... I think

那么,我说得对吗? 我是否需要对我想要返回的特定提交进行git结账? 或者在这个令人费解的过程中有什么我不了解的东西?

谢谢。

Git is a phenomenal tool, but I have yet to wrap my mind around the best way to undo pushed changes. Here's the situation.

I'm on a branch, and have pushed several commits to GitHub. It has since been decided that I've gone too far down the rabbit hole, and we need to scrap several of the commits I've done, and start over. Essentially, I need to reverse all of the pushed commits, back to a previous one. Here are the two commands that I think are appropriate

git revert # - creates a new commit that "undoes" the changes of one specific commit git checkout 'commit SHA' # - sets the head to that specific commit, wherein I will re-push to the repo, undoing my changes... I think

So, am I right? Do I need to do a git checkout on the specific commit I want to return to? Or is there something in this convoluted process that I am not understanding?

Thanks.

最满意答案

尝试git reset : http : //git-scm.com/docs/git-reset

Try git reset: http://git-scm.com/docs/git-reset

更多推荐

本文发布于:2023-08-01 19:17:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1363706.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:检出   revert   Git   pushed   undo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!