2

I need to revert below two commits :

user@007:~/git/project_demo$ git log --oneline
4736674 FIXED:Included src2.cpp file in code coverage.      
d7f6712 TASK:Introduced code coverage for selected project test cases. 
60542ef TASK: Implemented first version here.

How can I use this git revert command?

Should I use git revert twice or use git revert one time and pass the absolute commit SHA1 value.

I want to come to 60542ef commit and do the new changes on top of this commit.

Here I need to use git revert only instead of git reset.

1

2 Answers 2

3

If you want to keep history then follow below command,

git revert 4736674

and

git revert d7f6712

then make your changes.


if you do not want to keep history then go down 2 commit as below

git reset --hard HEAD~2

then perform your new changes and do

git push -f origin master 
3

Yes, just revert them in reverse chronological order

git revert 4736674 
git revert d7f6712

If you need/want to commit both reverts as one revert commit, just add -n to your first revert, it'll prevent the commit and you'll get everything reverted with the second command.

And by definition with git revert, no need to push with force as this doesn't break history.

Not the answer you're looking for? Browse other questions tagged or ask your own question.