switch to this branch, check that the git log and git revert tags do individually. Once you do this, go back to the desired branch, and then you can use git cherry-pick to select specific commits from the git links and merge them into the desired branch.
git checkout wrong_branch git revert commitsha1 git revert commitsha2 git checkout right_branch git cherry-pick commitsha1 git cherry-pick commitsha2
If the commits are grouped together and there are no commits after your dirty commits, you can even use git reset to get this wrong branch to the state immediately before your commits, and then repeat this with git cherry-pick to get your commit in the correct branch.
git checkout wrong_branch git reset commitsha3
Dhruva Sagar Jun 24 2018-11-11T00: 00Z
source share