A colleague of mine somehow pushed his HEAD revision of a release branch my team is working on to our main development branch. (This would be 145 commits improperly pushed)
I want to keep our commit history clean so I am toying with the idea if I should do anything, or just create a new Development branch to begin working on.
I cannot simply do a
git revert <last-trusted-sha>..HEAD
Because there are multiple merges on the branch (From when we do a pull request and Git creates a merge remote_currentbranch to currentbranch).
Is there any way to resolve this easily? Or do I just go commit by commit until it is corrected?
Thanks
To recover development
branch, you can use below commands:
git checkout development
git reset --hard HEAD~145
git push -f
Or if you know the last commit sha-1 value on the development
branch before commits on the release
branch were pushed to the development
branch, you can also use git reset --hard <last commit>
to replace the command git reset --hard HEAD~145
. Then the development
branch would be recovered.