I made some changes locally in my main branch and committed, but not pushed. Now, I changed my mind and I would like to create a new test branch, take all the changes that would be pushed, commit them to the new branch and remove from the main branch.
So (not a real output, wrote it by hand):
# get the code git clone ... # I am in the main branch git branch * main # ...do some changes... # and commit them git commit --all # I am ahead by 1 commit git status Your branch is ahead of 'origin/main' by 1 commit # I changed my mind, I don't want to # git push # I want to move those changes to a new branch git checkout -b test # WHAT NOW? # - move the changes that are "ahead" to the "test" branch # - restore the main branch to the state before the commits