简体   繁体   English

使用 Git 部署到 Heroku 时,如何解决子树上的“pushed branch tip is behind”?

[英]How do I solve “pushed branch tip is behind” on subtree when deploying to Heroku with Git?

I'm trying to push my build folder, dist-new, with this command:我正在尝试使用以下命令推送我的构建文件夹 dist-new:

git subtree push --prefix dist-new heroku master

Unfortunately, I get this error:不幸的是,我收到此错误:

error: failed to push some refs to 'https://git.heroku.com/it
ribe-frontend.git'
hint: Updates were rejected because a pushed branch tip is be
hind its remote
hint: counterpart. Check out this branch and integrate the re
mote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help'

I can't force the deployment, because git subtree does not have a force option.我无法强制部署,因为 git subtree 没有强制选项。

Googling around, I've seen a recommendation to do this:谷歌搜索,我看到了一个建议:

git push heroku git subtree split --prefix dist master:master --force

But that throws this error:但这会引发此错误:

error: unknown option `prefix'

Does anyone have any ideas?有没有人有任何想法?

Problem问题

You likely aren't using an up to date version of git您可能没有使用最新版本的 git

Solution解决方案

The prefix option is still available in the latest version of git (see here: https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh )前缀选项在最新版本的 git 中仍然可用(请参阅此处: https : //github.com/git/git/blob/master/contrib/subtree/git-subtree.sh

git subtree split -- prefix

Also you need to execute the command as a sub shell you can't just do:您还需要将命令作为子shell执行,您不能这样做:

git push heroku git subtree split --prefix dist master:master --force

You must do:你必须这样做:

git push heroku $(git subtree split --prefix dist master:master) --force

References参考

Git Subtree source code: https://github.com/git/git/blob/master/contrib/subtree/git-subtree.sh Git 子树源代码: https : //github.com/git/git/blob/master/contrib/subtree/git-subtree.sh

This worked:这有效:

https://coderwall.com/p/okrlzg/take-control-of-your-heroku-git-repository https://coderwall.com/p/okrlzg/take-control-of-your-heroku-git-repository

$ heroku plugins:install https://github.com/lstoll/heroku-repo.git
$ heroku repo:reset -a appname

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复Git中的问题:“更新被拒绝,因为推送的分支提示位于其远程对应的后面” - How to fix issue in Git: “Updates were rejected because a pushed branch tip is behind its remote counterpart” 如何在 git 中获取分支提示的提交 ID? - How do I get the commit ID of the branch tip in git? 如何解决“由于当前分支的尖端落后而导致更新被拒绝”? - How can I solve “Updates were rejected because the tip of your current branch is behind”? 如何强制覆盖我推送并重新设置的git分支? - How do I force the overwriting of a git branch I pushed and rebased? 如何将子树从本地分支推送到heroku master - How to git push subtree from a local branch to heroku master 上游项目强制推送到主节点后,如何修复 git 子树? - How do I fix a git subtree after the upstream project force pushed onto master? 当我运行“git push”时,我得到“您当前分支的提示在其远程后面”但当前分支没有上游跟踪分支 - When I run "git push" I get "tip of your current branch is behind its remote" but the current branche has no upstream tracking branch 如何解决git错误:重命名远程分支时“更新被拒绝,因为当前分支的提示落后” - How to resolve git error: “Updates were rejected because the tip of your current branch is behind” when renaming a remote branch Git提示位于当前分支的后面,冲突 - Git tip is behind of current branch, conflict 如何解决GitHub消息,其中显示当前分支的提示位于其远程对应的后面? - How do I resolve a GitHub message that says the tip of my current branch is behind its remote counterpart?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM