Bishal Gurung
Bishal Gurung

Reputation: 11

Revert the changes made to the master branch git

I didn't know i was working on the master branch and pushed all my changes into the master. Is there way i can pull all the changes from the master to the development and revert the changes made to the master to the original state ?

Upvotes: 1

Views: 2148

Answers (1)

yangli-io
yangli-io

Reputation: 17334

First, you should save your existing work by putting it in a separate branch

git checkout -b temporary

Then go back to master and remove the commits, you can change HEAD~[x] where x is the number of commits you want to go back.

git checkout master
git reset --hard HEAD~1
git push origin master -f

Upvotes: 1

Related Questions