I just made a perfectly good commit to the wrong branch. How do I undo the last commit in my master branch and then take those same changes and get them into my upgrade bran
4 years late on the topic, but this might be helpful to someone.
If you forgot to create a new branch before committing and committed all on master, no matter how many commits you did, the following approach is easier:
git stash # skip if all changes are committed
git branch my_feature
git reset --hard origin/master
git checkout my_feature
git stash pop # skip if all changes were committed
Now you have your master branch equals to origin/master
and all new commits are on my_feature
. Note that my_feature
is a local branch, not a remote one.