Working with git, after some ‘commit’, and a couple of ‘push’, I realized that am using the wrong branch!
Now I have to remove in some way my changes in wrong_branch
and commit and push the changes in right_branch
What’s the best (and simple) way to do that ?
switch to that branch, check the
git logandgit revertthose commits individually. Once you have done that, switch back to the desired branch and there you can then usegit cherry-pickto pick specific commits from the git refs and merge it into the right branch.If the commits are grouped together and there are no commits pushed after your dirty commits, you can even use
git resetto get that wrong branch to a state just before your commits and then follow that again usinggit cherry-pickto get your commits into the right branch.