GIT Tips At Weekend - Friday

Git Setup

Git Clone
git clone [repo]

clone the repository specified by [repo]. It defaully run git init and git remote add origin [repo]

Add colors by setting ~/.gitconfig file:
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
Highlight whitespace in diffs by setting ~/.gitconfig file:
ui = true
[color "diff"]
whitespace = red reverse
Add aliases by setting ~/.gitconfig file:
st = status
ci = commit
br = branch
co = checkout
df = diff
dc = diff --cached
lg = log -p
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
ls = ls-files
Show files ignored by git by setting ~/.gitconfig file:

ign = ls-files -o -i –exclude-standard


git config -e [--global]

Edit the .git/config [or ~/.gitconfig] file in your $EDITOR
git config –global ‘John Doe’
git config –global
Sets your name and email for commit messages

git config branch.autosetupmerge true

Tells git-branch and git-checkout to setup new branches so that git-pull(1)
will appropriately merge from that remote branch. Recommended. Without this,
you will have to add --track to your branch command or manually merge remote
tracking branches with “fetch” and then “merge”.

git config core.autocrlf true

This setting tells git to convert the newlines to the system’s standard
when checking out files, and to LF newlines when committing in

Note: You can add --global after git config to any of these commands to make it
apply to all git repos (writes to ~/.gitconfig).