1

I'm attempting to reset my git repo to a 2-3 version old commit. I'm trying to do the following:

git reset 70057f0

However this gives:

fatal: ambiguous argument '70057f0': unknown revision or path 
not in the working tree.

Use '--' to separate paths from revisions

What am I doing wrong?

Ali
  • 261,656
  • 265
  • 575
  • 769
  • possible duplicate of [Revert to previous Git commit](http://stackoverflow.com/questions/4114095/revert-to-previous-git-commit) – Joe May 25 '14 at 02:38

2 Answers2

1

try git reset --hard 70057f0

else, use git log, or a GUI to find the correct commit hash, then you can use reset.

*NOTE reset will only work properly if you havn't already pushed the commits, if you have pushed the commits, you will need to use revert which will create a new commit which undoes all previous commits to where you specify.

RaggaMuffin-420
  • 1,762
  • 1
  • 10
  • 14
  • I have already pushed the commits. With revert, should I just do `git revert `? – Ali Mar 14 '14 at 12:39
  • 1
    Reset works fine with pushed commits. It, however, requires you to use the `--force` flag when you push your newly reset branch, which can be a headache if you're collaborating with others, depending on people's familiarity with git. – joshtkling Mar 14 '14 at 12:42
  • this is true, but for good practice a reset should really be just for removing local commits... revert is much better because there is a reverse commit there, and it makes sense :) – RaggaMuffin-420 Mar 14 '14 at 12:44
  • Or, alternatively, you can do `git reset --hard 70057f01` and then `git push --force origin/your-branch`. This is rude, but If you care about Git history and no one fetched these commits yet. – vrybas Mar 14 '14 at 12:44
  • do i have to revert it through the revisions one by one? – Ali Mar 14 '14 at 13:12
  • no, git will take care of it, just put the revision you want to revert to in. – RaggaMuffin-420 Mar 14 '14 at 13:15
  • I'm trying `git revert a90b2960a0e5cf9aac0cb20d89510a3beba05ceb` and it says: `error: could not revert a90b296...hint: after resolving the conflicts, mark the corrected paths hint: with 'git add ' or 'git rm ' hint: and commit the result with 'git commit'` – Ali Mar 14 '14 at 13:19
  • Yeah resolve the conflicts! use `git status` to show which files are failing to merge, then resolve them. – RaggaMuffin-420 Mar 14 '14 at 13:35
  • I ended up sorting out this issue by checking out to the previous revision. – Ali Mar 15 '14 at 01:37
-1

The SHA1 you gave to git is invalid (it does not exist). Double check it by using git log and copy / pasting the SHA1 you want to revert to.

Alexandre DuBreuil
  • 5,431
  • 2
  • 19
  • 17