rollback git 1

rollback git

git reset --hard HEAD^

Here is what the above code is Doing:
1. git reset –hard HEAD^
This command will reset the current branch to the previous commit.
The –hard flag will also reset the working directory to match the commit.
This means that any changes you’ve made to the working directory will be lost.
If you don’t want to lose your changes, you can use the –soft flag instead.
This will only reset the branch to the previous commit, but it won’t change the working directory.
You can then use git stash to save your changes and git stash pop to restore them.
2. git push origin +master
This command will force push the master branch to the remote repository.
The + sign tells Git to force push the branch.
This is necessary because we’re pushing a branch that’s behind the remote repository.
If you don’t force push, Git will reject the push.

Similar Posts