如何将Heroku git存储库重置为初始状态? [英] How do I reset a Heroku git repository to its initial state?
问题描述
我有一个在git仓库中的web应用程序。由于历史原因,Web应用程序不在存储库的根目录,它位于名为网站
的文件夹中。除此之外,还有一些其他文件夹,以便我得到以下结构:
myApp
+ - .git
+ - otherFolder1
+ - otherFolder2
+ - otherFolder ...
+ - otherFolderN
+ - 网站
该网站在Heroku上运行。由于Heroku要求您的Web应用程序位于git存储库的根目录,直到现在我使用了一个构建过程,它将网站
文件夹复制到完全不同的(外部)文件夹中它自己的git仓库。然后,我可以从那里推到Heroku,一切都很顺利。
现在,因为git包含子树
命令这不再是必要的,因为我可以直接从我的初始文件夹,但只是网站
子文件夹,使用:
git subtree push --prefix = website heroku master
基本上,这是完美的。我只有一个问题:由于之前对Heroku的提交来自完全不同的git存储库,两者的历史记录并不匹配 - 所以Heroku检测到非快进推送,并拒绝 subtree
push。
那么我该如何处理这个问题呢?
git subtree push
没有 - force
选项(或类似的东西)。
我喜欢跟主意2一起去,但我不知道如何实现这个目标。
我的第一个方法是运行 git push heroku :master
,但Heroku检测到并拒绝它。
当然,我可以销毁应用程序并重新创建它,附加组件也没有了,我想避免这种情况。
其他想法?
对于您的情况,命令将是:
git push heroku`git subtree split --prefix website master`:master --force
I have got a web application within a git repository. Due to historic reasons the web application is not at the root of the repository, it is within a folder called website
. Beside that there are some other folders, so that I have got the following structure:
myApp
+- .git
+- otherFolder1
+- otherFolder2
+- otherFolder...
+- otherFolderN
+- website
The website is run on Heroku. As Heroku demands that your web application is at the root of a git repository, until now I used a build process which copied the website
folder to a completely different (external) folder with its own git repository. Then I was able to push from there to Heroku and everything was fine.
Now, since git includes the subtree
command this is not necessary any longer, as I could directly push from my initial folder, but just the website
sub-folder, using:
git subtree push --prefix=website heroku master
Basically, this works perfectly. I only have one problem: As the previous commits to Heroku came from a completely different git repository, the history of both doesn't match each other - so Heroku detects a non-fast-forward push, and rejects the subtree
push.
So how do I deal with this?
- Idea 1: Force push. Tried that, but doesn't work as
git subtree push
does not have a--force
option (or anything similar). - Idea 2: Clear Heroku's repository and start from scratch again.
I'd love to go with idea 2, but I have no idea of how to achieve this.
My first approach was to run a git push heroku :master
, but Heroku detects this and denies it.
Of course, I could destroy the app and recreate it, but then all domain assignments and add-ons are gone as well, and I'd like to avoid that.
Any other ideas?
You can nest git commands to execute force push.
For your case the command will be:
git push heroku `git subtree split --prefix website master`:master --force
这篇关于如何将Heroku git存储库重置为初始状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!