Moving master branch to original state before any commits

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


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.


尝试


git checkout master 

git reset --hard origin/master

链接地址: http://www.djcxy.com/p/37816.html

上一篇: 我如何`hg恢复

下一篇: 在任何提交之前将主分支移至原始状态