Theses are things that you run once. The log format and PS1 are my personal preferences so may need changing up for your needs.
git config --global color.ui true
git config --global format.pretty "%C(white dim) %h %C(yellow) %ar %C(cyan) %an %Creset %s"
Add this function to your ~/.bash_profile
__git_ps1 ()
{
local b="$(git symbolic-ref HEAD 2>/dev/null)";
if [ -n "$b" ]; then
printf " (%s)" "${b##refs/heads/}";
fi
}
You can then use this when you set your PS1
prompt value.
export PS1='\[\033[0;30m\]\u@$REALNAME\[\033[00m\]:\[\033[01;37m\]\w \[\033[0;32m\]$(__git_ps1)\[\033[00m\]\$ '
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
Then add this to your ~/.bash_profile
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
This allows to to automaticaly never track any of these files. Create a file ~/.gitignore_global
and add the following as a basic starter. This should stop most of the files that os's add, SASS cache and rogue SVN files.
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
.sass-cache
.svn
Save then run this command
git config --global core.excludesfile ~/.gitignore_global
git config --global help.autocorrect 1
Pretty self explanatory but these are some useful commands I use everyday.
git checkout -b BRANCHNAME
git branch -m OLDBRANCH NEWBRANCH
Don't if the commit is public
git commit --amend
git log | grep "NEEDLE"
git status -sb
git log -1 -- PATH/TO/FILE
git checkout -- PATH/TO/FILE