Last active
December 17, 2015 17:59
-
-
Save frontmesh/5649586 to your computer and use it in GitHub Desktop.
Sequence of a git commands for pushing commit to origin branch. Requires NodeJS to work. - git add .
- git commit -am ""
- git pull origin [current_branch]
- git push origin [current_branch] chmod +x git-push
sudo cp git-push /usr/bin/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/node | |
var sys = require('sys') | |
, exec = require('child_process').exec | |
, current_branch | |
, commit_message = process.argv[2]; | |
function puts (error, stdout, stderr){ | |
sys.print('stdout: ' + stdout); | |
sys.print('stderr: ' + stderr); | |
if(error !== null) { | |
console.log('exec error: ' + error); | |
} | |
} | |
exec('git branch|grep "*"', function(err, stdout, stderr){ | |
if(err == null){ | |
current_branch = stdout.substring(2); | |
console.log(current_branch); | |
if( commit_message ){ | |
// add all unversioned files | |
exec('git add .', function(error,stdout, stderr){ | |
//do a commit on a current branch | |
exec('git commit -m "' + commit_message +'"', function(error,stdout, stderr){ | |
sys.print('stdout: ' + stdout); | |
sys.print('stderr: ' + stderr); | |
if(error !== null) { | |
console.log('exec error: ' + error); | |
} else { | |
//do a pull origin of a current branch | |
exec('git pull origin ' + current_branch, function(error, stdout,stderr){ | |
sys.print('stdout: ' + stdout); | |
sys.print('stderr: ' + stderr); | |
// do a push of a current branch | |
exec('git push origin ' + current_branch, function(error, stdout,stderr){ | |
sys.print('stdout: ' + stdout); | |
sys.print('stderr: ' + stderr); | |
}); | |
}); | |
} | |
}); | |
}); | |
} else { | |
console.log("You need to provide a commit message"); | |
} | |
} else { | |
console.log('exec error: ' + err); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment