我在我的主分支本地进行了一些更改并提交,但没有推送。现在,我改变了主意,我想创建一个新的测试分支,接受所有将要推送的更改,将它们提交到新分支并从主分支中删除。
所以(不是真正的输出,是手写的):
# 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