2014-09-06 90 views
0

我有一個分支名爲hfix。我在origin/hfix上有一些骯髒的提交。當我發出以下命令時:爲什麼git reset --hard和push --force不能恢復我的遠程分支

git reset --hard abd000b3ce70557f05a469d580fc8f3bf1c3a8b2 

我的本地頭指針向後移動到我想要的位置。現在我想要做的就是給力我的遠程分支有相同的歷史作爲我的地方,所以我發出:

git push --force origin hfix 

,但我得到了以下錯誤:

Total 0 (delta 0), reused 0 (delta 0) 
remote: error: denying non-fast-forward refs/heads/hfix (you should pull first) 
To [email protected]:/var/local/fxxx/local_core.repo 
! [remote rejected] hfix -> hfix (non-fast-forward) 

我不想拉,因爲它會讓我的本地像遠程的一樣。我該如何清理遠程分支作爲我的本地分支?

回答

2

您的遠程存儲庫極有可能在其配置中爲denyNonFastforwards = true。如果您將其切換爲false,則git push --force origin hfix應該按照您的預期工作。

+0

在我的服務器上的'〜/ .gitconfig'不是本地沒有'denyNonFastforwards'這樣的事情 – ALH 2014-09-06 08:31:25

+0

好的,加到它然後... – aleroot 2014-09-06 08:53:56

+0

對不起,問:當我們沒有那個參數時,意味着它已被默認設置爲true,我應該將其設置爲false? – ALH 2014-09-06 09:09:40

相關問題