Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reverting to a specific sha or commit

I'm trying to revert to a specific commit ( 3d5575f8e4c97ddab8ad5d540fee4664c04db75d ), but when i do:

git revert 3d5575f8e4c97ddab8ad5d540fee4664c04db75d

it says:

fatal: 'revert' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.

I don't care those changes, and I also want to lose those changes, revert to that commit (soft revert, dont want to lose the files) THEN repull down changes. My local stuff is all messed up. Any help?

like image 400
Oscar Godson Avatar asked Nov 17 '11 02:11

Oscar Godson


2 Answers

I think you want to use git reset 3d5575f8e4c97ddab8ad5d540fee4664c04db75d. This will keep your working files as is, but reset your HEAD to the commit you specified. Additionally, it should reset your index as well (clears out files you have selected to commit, add, remove, etc).

If you want to get rid of all the changes to your working files, use git reset --hard 3d5575f8e4c97ddab8ad5d540fee4664c04db75d.

like image 158
DanR Avatar answered Oct 10 '22 20:10

DanR


You want to do:

 git reset 3d5575f8e4c97ddab8ad5d540fee4664c04db75d

This will "reset" you to the commit specify.

git revert just creates a new commit which reverts the changes of that commit, which is probably not what you want.

like image 31
manojlds Avatar answered Oct 10 '22 20:10

manojlds