Git Basics
December 7, 2014
Download:
GitBasics.pdf
GitBasics.pptx
Git is a revision control system. It's a bit daunting at first, but learning Git can be a good way to incorporate backups and safe "branching" exploration into your workflow.
Git works best on text documents like source code or plaintext formats like LaTeX or Markdown, not opaque formats like Word docs or CAD/Photoshop files. You can still use it for those formats, but you won't really be able to do line-based diffs or easily resolve conflicts between versions.
Additional links:
Posters
Here are some posters I made for my labmates that cover the basic operations for Git:
Git Config
[user]
name =
email =
signingkey =
[alias]
last = log -1 HEAD
unstage = reset HEAD --
undo = reset --soft HEAD^
stash-all = stash save --include-untracked
ss = stash-all
a = add --patch
aa = add .
amend = commit --amend
c = commit
cm = commit -m
cnv = commit --no-verify -m
ca = commit -am
co = checkout
cb = checkout -b
b = checkout
bb = checkout -b
br = branch
bra = branch -a
brr = branch -r
f = fetch --prune
fo = fetch --prune origin
m = merge
ps = push
pl = pull
pr = pull --rebase
pf = push --force-with-lease
l = log
lp = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
s = status
d = diff
g = grep -i
[branch]
sort = committerdate
[column]
ui = auto
[commit]
verbose = false
gpgsign = true
[diff]
indentHeuristic = true
algorithm = histogram
colorMoved = plain
renames = true
mnemonicPrefix = true
[difftool]
prompt = false
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
[fetch]
prune = true
pruneTags = true
all = true
[grep]
patternType = perl
[help]
autocorrect = prompt
[init]
defaultBranch = main
[interactive]
[merge]
keepBackup = false
conflictstyle = zdiff3
[mergetool "p4merge"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$REMOTE\"" "\"$PWD/$MERGED\""
keepTemporaries = false
trustExitCode = false
keepBackup = false
[pull]
rebase = true
[push]
default = simple
autoSetupRemote = true
followTags = true
# brew install bat
[pager]
show = bat
log = bat
diff = bat
[rebase]
autosquash = true
autostash = true
updateRefs = true
[tag]
sort = version:refname
gpgSign = true
[gpg]
format = ssh
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true