Question

I apologise if this question has already been asked and answered, but I could'nt find it.

Basically, instead of creating a branch, I have implemented a alpha version of an application in the master branch and committed a few times over the top of a forked version of the old application.

Is it possible to revert the master branch back to its original state?

Ben

Était-ce utile?

La solution

Use git log to display the commits to the master branch. From this information determine how many commits you would like to remove.

$ git log
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <schacon@gee-mail.com>
Date:   Mon Mar 17 21:52:11 2008 -0700

    changed the version number

Then use git rebase to remove the specified number of commits.

git reset --hard HEAD~3 <--- Number of commits

Note that using --hard will cause all current changes to be lost. This answer also assumes that the commits you desire to remove are in a sequential order.

If your working in a collaborative environment use git revert instead of reset. This will issue a new commit that overwrites the old commits.

git revert HEAD~3..HEAD  <--- 3 being number of commits to overwrite

See this article for more information.

Autres conseils

try

git checkout master 

git reset --hard origin/master

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top