The problem is that you are running the runSequence plugin to run tasks in parallel. The solution is very simple:
// gulp task to commit and push data on git gulp.task('git', function(){ return runSequence('gulp:commit', 'gulp:push', 'gulp:done'); });
By doing this, you will make sure that gulp: push will only be started after gulp: commit is completed and after gulp: done is completed .
In addition, I recommend that you return the stream to gulp: click and use the completed callback parameter in gulp: done , unless you do that gulp does not know when the following tasks are completed:
// git commit task with gulp prompt gulp.task('gulp:commit', function(){ // just source anything here - we just wan't to call the prompt for now return gulp.src('./*') .pipe(prompt.prompt({ type: 'input', name: 'commit', message: 'Please enter commit message...' }, function(res){ // now add all files that should be committed // but make sure to exclude the .gitignored ones, since gulp-git tries to commit them, too return gulp.src([ '!node_modules/', './*' ], {buffer:false}) .pipe(git.commit(res.commit)); })); }); // Run git push, remote is the remote repo, branch is the remote branch to push to gulp.task('gulp:push', ['gulp:commit'], function(cb){ return git.push('origin', 'master', cb, function(err){ if (err) throw err; }); }); // # task completed notification with green color! gulp.task('gulp:done', ['gulp:push'], function(done){ console.log(''); gutil.log(gutil.colors.green('************** Git push is done! **************')); console.log(''); done(); });
EDIT: you should return the stream to the gulp: commit task, I changed my answer to show you how to do this.
source share