Skip to content

Instantly share code, notes, and snippets.

@Xtremefaith
Last active January 4, 2016 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xtremefaith/8591296 to your computer and use it in GitHub Desktop.
Save Xtremefaith/8591296 to your computer and use it in GitHub Desktop.
All kinds of helpful aliases and configuration options. Check them out!

##Basics --st: status

git config --global alias.st status 

--ci: commit -m

git config --global alias.ci 'commit -m'

--co: checkout

git config --global alias.co checkout

--merge-to: merge-to <branch>

git config --global alias.merge-to "!gitmergeto() { export tmp_branch=`git branch | grep '* ' | tr -d '* '` && git checkout $1 && git merge $tmp_branch && git checkout $tmp_branch; unset tmp_branch; }; gitmergeto"

##Logs

--lg: log (default option)

git config --global alias.lg 'log --graph --date-order --date=relative --pretty=format:"%C(yellow)%h: %Cred - %an - %Cgreen %C(cyan)%ar:%Creset%n%s%n" --color'

--lg1: log (alternate format 1)

git config --global alias.lg1 'log --graph --all --format=format:"%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)" --abbrev-commit --date=relative'

--lg2: log (alternate format 2)

git config --global alias.lg2 'log --graph --all --format=format:"%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(bold white)— %an%C(reset)" --abbrev-commit'

##Stashing --stashname: stash apply

Need to save stash by name so you remember what code you stashed here

git config --global alias.stashname 'stash save '

--stashapp: stash apply stash@{#}

Very simple way to apply stashes by name

git config --global alias.stashapp '!f() { git stash apply stash^{/$*}; }; f'

--stashdrop (not working, open to suggestions)

Very simple way to drop stashes by name

git config --global alias.stashdrop '!f() { git stash drop $*; }; f'

#Configration

##Mac

###Bash Branch and Color Hints (bash_profile)

# Git branch in prompt.
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}

export PS1="\[\033[33m\]\u@\h\[\033[00m\] \[\033[31m\]\W\[\033[00m\]\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment