简体   繁体   English

如何恢复我的推或git上的提交

[英]how to revert back my push or commit on git

I have create 2 commit and want to revert back from git 我创建了2个commit并想从git中恢复

branch name jaskaran_branch 分支名称jaskaran_branch

commit id 9cb63da53b02899a67005f1ae6100ce1783433f3
commit id 9cb63da53b02899a67005f1ae6100ce1783445f7

I have tried so many things but maybe I am wrong anywhere. 我已经尝试了很多事情,但是也许我在任何地方都错了。

Please let me know how can do 请让我知道该怎么办

If the commit id of the branch prior to those to commits is xyz. 如果分支提交之前的分支的提交ID为xyz。 Use git push origin xyz:jaskaran_branch . 使用git push origin xyz:jaskaran_branch This checkouts the commit prior to the 2 commits you've done. 这会在您完成2次提交之前检出提交。

Sometimes you may want to undo a whole commit with all changes. 有时您可能想撤消所有更改的整个提交。 Instead of going through all the changes manually, you can simply tell git to revert a commit, which does not even have to be the last one. 无需手动进行所有更改,您只需告诉git还原一次提交即可,甚至不必是最后一次提交。 Reverting a commit means to create a new commit that undoes all changes that were made in the bad commit. 还原提交意味着创建一个新的提交,该新提交将撤消对该错误提交所做的所有更改。 The bad commit remains there, but it no longer affects the the current master and any future commits on top of it. 错误的提交仍然存在,但不再影响当前的主服务器以及它之上的任何将来的提交。

Try this one 试试这个

git revert {commit_id}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM