1

Possible Duplicate:
How do you roll back (reset) a git repository to a particular commit?

I have the following revisions in order r1, r2, r3, r4, r5 in origin/master.

  1. How do I revert the entire code base to a previous snapshot in a certain branch (say r3)
  2. If I do [1], will subsequent commits say r4', r5' be on top of r3 and we will not have any reference to r4, r5 in the code base.
Community
  • 1
  • 1
priya
  • 24,861
  • 26
  • 62
  • 81

1 Answers1

2
  1. git reset --hard r3 will revert your currently checked out branch back to r3.
  2. Subsequent commits will be on top of r3. You will lose any reference to r4 and r5, unless something else is pointing to it besides master.

The first part of your question is a duplicate, but I created this answer since you are asking for a little more detail.

Community
  • 1
  • 1
Andy
  • 44,610
  • 13
  • 70
  • 69
  • 2
    The easiest way to "keep" `r4` and `r5` is to do `git branch newbranch` before the `git reset` — `master` will be reset to point at `r3` but `newbranch` will keep pointing at `r5`. – hobbs Feb 23 '12 at 18:56