我有一个使用Serve的项目,并使用Git进行版本控制.Serve创建一个output包含我想要部署到Heroku的静态文件的文件夹.
我不想部署Serve项目本身,因为Heroku Cedar堆栈似乎不太喜欢它,但最重要的是我想利用Heroku对静态网站的大力支持.
有没有办法将子文件夹部署到git远程?我应该在output文件夹中创建一个Git仓库(听起来不对)并将其推送到Heroku?
ans*_*ans 204
通过git-subtree有一个更简单的方法.假设您要将文件夹"output"作为根目录推送到Heroku,您可以执行以下操作:
git subtree push --prefix output heroku master
Run Code Online (Sandbox Code Playgroud)
目前看来git-subtree被包含在git-core中,但我不知道git-core的版本是否已经发布.
我有类似的问题.在我的情况下,删除heroku存储库中的所有内容并将其替换为我子目录中的任何内容从来都不是问题.如果是这种情况,您可以使用以下bash脚本.只需将它放在您的Rails应用程序目录中即可.
#!/bin/bash
#change to whichever directory this lives in
cd "$( dirname "$0" )"
#create new git repository and add everything
git init
git add .
git commit -m"init"
git remote add heroku git@heroku.com:young-rain-5086.git
#pull heroku but then checkback out our current local master and mark everything as merged
git pull heroku master
git checkout --ours .
git add -u
git commit -m"merged"
#push back to heroku, open web browser, and remove git repository
git push heroku master
heroku open
rm -fr .git
#go back to wherever we started.
cd -
Run Code Online (Sandbox Code Playgroud)
我相信有很多方法可以改进这一点 - 所以请随时告诉我如何!
我从John Berryman所说的开始,但实际上如果你根本不关心heroku git历史可能会更简单.
cd bin
git init
git add .
git commit -m"deploy"
git push git@heroku.com:your-project-name.git -f
rm -fr .git
Run Code Online (Sandbox Code Playgroud)
我想官方git subtree是最好的答案,但我有问题得到子树在我的Mac上工作.
| 归档时间: |
|
| 查看次数: |
29751 次 |
| 最近记录: |