Reputation: 15
Is it possible to undo one or two faulty commits I have made to Github. I'm not very good at coding either so if there's a way to do it without coding, that would be great.
Thank you very much
Upvotes: 0
Views: 49
Reputation: 29441
You can do this via doing the following command in your local workspace:
git reset --merge <hash>
Where <hash>
is the commit prior to the commits that you want to revert.
The above command is enough if you haven't pushed to GitHub. If you have pushed to GitHub, you then run the following to force an update of the remote branch:
git push --force origin <branch>
(Note: This is assuming that your remote is named origin
, but rename as appropriate.)
Note that this re-writes history on the remote branch, and is not recommended if other developers are using the same branch. If you know who the developers are, you can communicate with them to delete their local copies of the modified branch and ask them to run git fetch
to get a new copy of the branch.
Upvotes: 2