Skip to content

Instantly share code, notes, and snippets.

@ZeroDragon
Last active December 27, 2015 01:09
Show Gist options
  • Save ZeroDragon/7243402 to your computer and use it in GitHub Desktop.
Save ZeroDragon/7243402 to your computer and use it in GitHub Desktop.
Bash file to automatize git stages

#Custom git commit

##Install

  1. Save this bash file to a safe place
  2. give it execute permissions chmod +x stage.sh
    [3] create an alias on your .bash_profile or .zshrc
    alias stage='. ~/path-to-file/stage.sh'

##Usage $stage 'commit message'
Will stage all files (Modified, Deleted, Untracked, New...)
Will create a new commit with 'commit message' as message

$stage
Will show a git status (short).
Then will ask for a commit message. If the commit message is empty it will abort the process.

##Notes
On every succeded workflow it will delete all the .DS_file instances on the repository (we all hate those)

To pimp your results you can define colors on the ~/.gitconfig file:

[core]
        excludesfile = ~/.gitignore
[color]
        ui = true

Protip: define your .DS_Store files on ~/.gitignore to inherit them to all your repositories

##Screnshot

if [[ $* != "" ]]; then
find . -name '*.DS_Store' -type f -delete
git add -A
git commit -am "$*"
else
echo 'Repository status:'
git status -sb
echo
echo 'Set a commit message (leave blank to cancel): '
read mensaje
if [[ $mensaje != "" ]]; then
find . -name '*.DS_Store' -type f -delete
git add -A
git commit -am "$mensaje"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment