Skip to content

Instantly share code, notes, and snippets.

@tgvashworth
Last active December 17, 2015 22:09
Show Gist options
  • Select an option

  • Save tgvashworth/5680243 to your computer and use it in GitHub Desktop.

Select an option

Save tgvashworth/5680243 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Commit and sync to Github
# To install, run:
# cd /usr/local/bin && wget -O commit-and-sync https://gist.github.com/phuu/5680243/raw/gistfile1.sh && chmod u+x commit-and-sync
# then restart yaw terminals.
BRANCH="$(git symbolic-ref HEAD 2>/dev/null)"
# Reconnaissance
echo
echo " Commit and sync to GitHub"
echo
echo " Which remote? Your options are:"
echo
git remote
echo
read -p " Remote name : " -r REMOTE
read -p " Commit message : " -r MSG
# Make sure all is well
echo
echo " Ok."
echo
echo " Committing all changes, pulling from $REMOTE, and pushing."
read -p " Happy? [y/N] : " -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
echo " Here we go..."
echo
git add -A &&
git commit -m $MSG &&
git pull $REMOTE $BRANCH &&
git push $REMOTE $BRANCH
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment