I have 5 branches master, branch-1, branch-2, branch-3 and branch-4.
I made some changes to branch-3 and merged to master and again did it twice, now I want to go back to the stage before all the 3 merge, I can checkout to that commit and create another branch which contains the data how I need it .
git checkout 1ba671a79a0cc57129768ce1ad0218e17841e4d9
git checkout -b "experimental-branch"
If you really want to reset your
master branch to this commit, then just use:
git reset --hard 1ba671a7
This will reset your
master branch to this commit. But keep in mind this will rewrite the history of this branch. This means that it could cause problems for anyone else sharing the branch (I'm assuming that no one else is sharing at the moment).
To push the updated
master you will need to use:
git push --force origin master
to force the branch to the repository.
If you are trying to revert commits on a publicly shared branch, you really should consider using
git revert instead.