[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gits] n00b question about reverting changes
Suresh> we have a document revision that I?ll call GOOD. Three
Suresh> revisions later, the document got trashed because of someone
Suresh> not fetching before editing or something like that. call the
Suresh> new version BAD. if I want to change the master version back to
Suresh> GOOD, what is the easiest way to do this ? do I have to muck
Suresh> around with rebase ?
If you are talking about a shared repository, a recommended practice would be
to add commits that "undo" the last three commits. This is a job for git
revert.
If your master-branch history looks like this:
--> GOOD --> work --> work --> BAD
Then you can get "undo" the last three commits by doing:
git revert HEAD~2..HEAD
This creates new commits that undo the the commits since GOOD. You can then
push these commits up to the shared repository in the usual way.
There are ways to remote the bad commits entirely, but this can be confusing if
you are sharing a repository with other people. So I don't mention them here!
Eric.
--
-------------------------------------------------------------------------------
Eric Eide <eeide at cs.utah.edu> . University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX