git分支撤消提交
我不小心忘了打开一个新分支,并将我的更改提交给了主机,但还没有将它们推送到远程回购。现在我得到了一条消息:“您的分支比‘origin/master’提前1个提交。” 我想做的是使我的主机与远程回购的主机相同—通过恢复到以前的状态或其他方式—然后打开一个从那里推送到远程的分支。我不介意重新进行我在上一次意外提交中所做的更改 当我:git分支撤消提交,git,Git,我不小心忘了打开一个新分支,并将我的更改提交给了主机,但还没有将它们推送到远程回购。现在我得到了一条消息:“您的分支比‘origin/master’提前1个提交。” 我想做的是使我的主机与远程回购的主机相同—通过恢复到以前的状态或其他方式—然后打开一个从那里推送到远程的分支。我不介意重新进行我在上一次意外提交中所做的更改 当我: cemgun@db05:~/mini$ git reset --hard HEAD is now at 2e2adc9 SHBDN-8584 changes cemgu
cemgun@db05:~/mini$ git reset --hard
HEAD is now at 2e2adc9 SHBDN-8584 changes
cemgun@db05:~/mini$ git reset --hard
HEAD is now at 2e2adc9 SHBDN-8584 changes
cemgun@db05:~/mini$ git checkout -f
Your branch is ahead of 'origin/master' by 1 commit.
cemgun@db05:~/mini$ git checkout -f
Your branch is ahead of 'origin/master' by 1 commit.
我仍然在我的意外犯
当我:
cemgun@db05:~/mini$ git reset --hard
HEAD is now at 2e2adc9 SHBDN-8584 changes
cemgun@db05:~/mini$ git reset --hard
HEAD is now at 2e2adc9 SHBDN-8584 changes
cemgun@db05:~/mini$ git checkout -f
Your branch is ahead of 'origin/master' by 1 commit.
cemgun@db05:~/mini$ git checkout -f
Your branch is ahead of 'origin/master' by 1 commit.
我仍然在我的意外犯
有什么建议吗?谢谢您的时间。试试:
$ git reset --soft HEAD^
$ git checkout -b new_branch
这将撤消最后一次提交,保留工作repo中的更改,然后创建包含这些更改的新分支。然后可以在新分支中创建新提交