0

I have create 2 commit and want to revert back from git

branch name 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

Sandeep
  • 619
  • 1
  • 7
  • 18
  • 2
    Possible duplicate of [Undoing a 'git push'](https://stackoverflow.com/questions/1270514/undoing-a-git-push) – ech0 Jul 12 '18 at 11:53
  • git push -f origin last_known_good_commit:branch_name I try this : ( – Sandeep Jul 12 '18 at 11:54
  • That is not the exact command that you're supposed to use. You're supposed to replace last_known_good_commit with the id of the last known good commit, and branch_name with the name of your branch. You should read the post. – ech0 Jul 12 '18 at 11:55
  • ok i will try this – Sandeep Jul 12 '18 at 11:58
  • Possible duplicate of [How to undo the most recent commits in Git?](https://stackoverflow.com/questions/927358/how-to-undo-the-most-recent-commits-in-git) – Liam Jul 12 '18 at 12:05

2 Answers2

0

If the commit id of the branch prior to those to commits is xyz. Use git push origin xyz:jaskaran_branch . This checkouts the commit prior to the 2 commits you've done.

0

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. 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}
mishri
  • 66
  • 3