If you have not posted your change, the easiest way to do this is to kill the last commit in branch1 (note: this will completely destroy everything that the last commit entered):
git checkout branch1 git reset
then check for the correct branching and copy your change there.
If you posted the change, you can still kill the last commit, but then you will have to git push --force , which you may not have permission, and even if you did, it can cause a lot of grief for other users of this repository.
Instead, you should simply return the wrong change:
git revert <bad_commit>
and repeat it in the correct branch.
source share