Search code examples
gitgit-revert

Use of git revert for reverting two commits


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.


Solution

  • 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