I made changes to several files, committed and pushed them to the master only to realize I was on the wrong branch for the commits and push. How can I undo this? I am not sure if git reset will give me what I want.
1 Answer
To avoid having to rewrite the history you can use git revert.
This will create a new commit that is the inverse of the commit you accidentally pushed.
Find the sha's of the commits you pushed and run this command for each sha:
git revert <sha> Then push your revert commits.
1 Comment
Angelfirenze
I did 'git revert' just now and it seems to be exactly what I was looking for. Thanks for posting this! I've had a lot of trouble keeping my files going to the right branches and this was just what I've needed.
resetandmerge --ff-onlyto keep your tree intact.