How to Undo git command?

How to Undo git command?

Hello Guys , 

Are you working with Git and have you committed your files in wrong branch?

Don’t worry? We are here to help you to rectify this issue

For example you have 2 branches branch-1 and branch-2

you are working on 1 file test.php

and you committed in branch-1 instead of branch-2

If you didn’t pushed your code you can still revert it.

Just run command

git reset –soft HEAD~1

and Then switch to you branch with git checkout branch-2 and add files and commit

Hope this solution will help you in your development process

Thanks and Keep Visiting 😊

Leave a Reply
Your email address will not be published. *