2012-10-15 49 views
0

我意外地忘了打開一個新的分支並將更改提交給主服務器,但沒有將它們推送到遠程回購站。現在我有這樣的信息:「你的分支在1次提交之前是'原點/主'之前的。」git分支撤消提交

我想要做的就是讓我的主人在遠程回購中與主人一樣 - 通過恢復到以前的狀態或其他方式 - 然後打開一個分支,並從那裏推送到遠程。我不介意重新修改我在之前的意外提交中所做的更改。

當我:

[email protected]:~/mini$ git reset --hard 
HEAD is now at 2e2adc9 SHBDN-8584 changes 
[email protected]:~/mini$ git reset --hard 
HEAD is now at 2e2adc9 SHBDN-8584 changes 

我還在我的意外提交。

當我:

[email protected]:~/mini$ git checkout -f 
Your branch is ahead of 'origin/master' by 1 commit. 
[email protected]:~/mini$ git checkout -f 
Your branch is ahead of 'origin/master' by 1 commit. 

我還在我的意外提交。

有什麼建議嗎? Thx爲你的時間。

回答

2

嘗試:

$ git reset --soft HEAD^ 
$ git checkout -b new_branch 

這將撤消最後一次提交,而使變化工作回購,然後創建一個包含這些變化new_branch。然後您可以在新分支中創建一個新的提交。