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 we
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
For those coming here from Yeoman's (lacking) deployment guide, there's a much, much better and easier solution developed by X1011 and I urge you all to make your lives easier and use it!
In contrast to the already issue-prone subtree method, this script actually retains your development commit delta history on your dist
/build
/release
branch - and, you don't even need to track the dist
folder in your development branches.
The setup process might look intimidating, but trust me, it's not. It took me less than 10 minutes to set up and it just worked as promised on the first run, even on a Windows machine.
If you'd like to automate it with Grunt, it is pretty easy. That's how I did it:
deploy.sh
to your main project folder.grunt-shell
with node through this command: npm install grunt-shell --save-dev
(--save-dev
will add grunt-shell
to your project's dev dependencies, in case you didn't already know). You may also use grunt-exec
, they basically do the same thing, AFAIK.Gruntfile.js
, add the following object to initConfig
:initConfig
object shell: {
deployverbose: {
command: 'sh deploy.sh -v',
options: {
stdout: true,
stderr: true
}
},
deploy: {
command: 'sh deploy.sh',
options: {
stdout: true,
stderr: true
}
}
}
5 . Register a new task, or add it to your existing build
task (make sure you you declare the target
parameter):
grunt build:deploy
if (target && target.indexOf('deploy') > -1) {
tasks.push('deploy');
}
grunt deploy
, also allows the --verbose
flag:grunt.registerTask('deploy', 'standalone deploy command', function () {
if (grunt.option.flags().indexOf('--verbose') > -1) {
grunt.task.run('shell:deployverbose');
} else {
grunt.task.run('shell:deploy');
}
});