git checkout main-branch # just to be sure you are on main-branch
git checkout -b main-branch-backup # now you have all commits (like a copy) from main-branch here
git log # verify in the commit log history, all commits will be here
git checkout main-branch # move back to main-branch
git checkout -b test-removing # like main-branch-backup but here you remove things
# assume you need to remove the last two commits you can do like so or change the number from the next line
git reset --hard HEAD~2
# if it worked you can do the same on main-branch, if it did not work
# as you expected, remove the branch test-removing and start again
1条答案
按热度按时间7vux5j2d1#
尝试以下命令:
字符串