2015-10-16 37 views
19

我们使用子树部署来部署Yeoman项目的子目录。在我们的案例中,该分公司被称为生产,而不是gh-页如何强制子树推覆盖远程更改?

这完美地工作,直到昨天,当Git的服务器拒绝了命令git subtree push --prefix dist origin production,说

! [rejected]  9fe1683aa574eae33ee6754aad702488e0bd37df -> production (non-fast-forward) 
error: failed to push some refs to '[email protected]:web-and-new-media/graduation2015.git' 
hint: Updates were rejected because a pushed branch tip is behind its remote 
hint: counterpart. 

如果我切换到生产分支机构本地(这是干净的),git pull返回Your branch is up-to-date with 'origin/production'.即使我使用--rebase选项。

我可以通过我们的Web UI在服务器上看到生产分支的内容,没有什么不应该出现,就像我期望的dist目录的编译输出一样。

为此,我似乎应该安全地强制覆盖这些文件,但是如何? git subtree push没有--force选项。

+0

'git subtree split --prefix dist origin origin'命令也失败:'致命的:模糊的参数'origin':未知的版本或路径不在工作树中。' – ele

+0

好吧,现在我真的难住了。我运行了'git subtree pull --prefix dist origin production',这确实给我留下了一个与我改变的代码有关的合并冲突,所以我解决了这个问题并且再次运行'git subtree push --prefix dist origin origin production'。只能再次失败,并再次出现相同的错误。 – ele

回答

30

诀窍是链上的子树被分成了强制推送:

git push origin `git subtree split --prefix dist master`:production --force 

我得到这个从http://clontz.org/blog/2014/05/08/git-subtree-push-for-deployment/补充协议,究竟是谁引用堆栈溢出this答案。我之前已经浏览过这个,但是史蒂夫克朗茨的帖子让我点击了它。

+1

此解决方案因“致命:不明确的参数'publish-dev':未知版本或路径不在工作树中”而失败。“ –

+0

更新后的链接http://clontz.org/blog/2014/05/08/git-subtree-push-for-deployment/ –

+0

有没有人解决了致命的含糊不清的争论问题? –