Last active
August 29, 2015 14:16
-
-
Save jgpeak/7ed03143b1fab6f62829 to your computer and use it in GitHub Desktop.
Bash script to add helpful custom Git commands to a system.
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
# Description: Custom command to perform git add and git commit together. | |
# Execution Command: git add-commit -m 'My commit message' | |
git config --global alias.add-commit '!git add -A && git commit' | |
# Description: Custom command to update a branch with changes from the remote master. | |
# Execution Command: git update-branch | |
git config --global alias.update-branch '!git checkout master && git pull && git checkout - && git rebase master' | |
#Description: Custom command to remove all merged local branches | |
# Execution Commad: git remove-merged | |
git config --global alias.remove-merged '!git checkout master && git branch --merged | grep -v "\*" | xargs -n 1 git branch -d' | |
# Description: Add some commmon git shortcuts | |
# Reference Source: http://gitready.com/intermediate/2009/02/06/helpful-command-aliases.html | |
git config --global alias.st status | |
git config --global alias.ci commit | |
git config --global alias.br branch | |
git config --global alias.co checkout | |
git config --global alias.df diff | |
git config --global alias.lg log -p | |
git config --global alias.rb rebase | |
## Custom Edit to set Sublime as default Text Editor. | |
git config --global core.editor "subl -n -w" |
git add -a
returns an error for me:
$ git --version
git version 2.2.1
hub version 1.12.1
$ git add -a
error: unknown switch `a'
usage: git add [options] [--] <pathspec>...
another (and simpler) way to do the update-branch (that does not touch your local master branch) would be: git fetch; git rebase origin/master
Be very careful with rebasing changes you have already pushed, though!!!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can add those things to the file ~/.gitconfig directly instead of using git config --global to do so: