2014-09-06 466 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

相关问题