commit to different branch code example
Example 1: how to save updated commits to another branch
git stash
git checkout other-branch
git stash pop
Example 2: git put commit on different branch
git checkout existingbranch
git merge master
git checkout master
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.
git checkout existingbranch