Skip to content

Instantly share code, notes, and snippets.

@cyrillbrito
Last active March 12, 2019 20:40
Show Gist options
  • Save cyrillbrito/ffa8790f83f809b2a2f0dc40f8615f21 to your computer and use it in GitHub Desktop.
Save cyrillbrito/ffa8790f83f809b2a2f0dc40f8615f21 to your computer and use it in GitHub Desktop.
The code will run git add, git commit and git push in a attempt to simplify using git in the console.

Git Push

This script is my attempt of simplifying git, by putting tree git commands in one. The sript will git add, git commit and git push. This will result in a simpler command but a lot less flexible. The script will always add all the files to the commit and pust to origin master. To use the command you need to be in the directory of the repository and use the command $ gitpush commitMessage. Example: $ gitpush Updated readme file

Versions:

0.01 (2016-05-05)
   Initial drop

0.02 (2016-05-06)
   Added keyboard interruption handler
   Fixed commit message
#!/usr/bin/env python
#
# File name: gitpush
# Description: This will semi automate git add, commit and push
# Author: Cyrill Brito
# Date created: 05/05/2016
# Version: 0.2
# Usage: $ gitpush commitMessage
# Python version: 2.7
import subprocess
import sys
if len(sys.argv) < 2:
print '$ gitpush commitMessage'
sys.exit(1)
try:
sys.argv.remove(sys.argv[0])
message = ' '.join(sys.argv)
# git add --all
subprocess.call(['git', 'add', '--all'])
# git commit -m _____
subprocess.call(['git', 'commit', '-m', message])
# git push origin master
subprocess.call(['git', 'push', 'origin', 'master'])
except KeyboardInterrupt:
print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment