10 things you didn't know about git

Conventions

commit = a commit SHA1 hash
ref = a relative pointer HEAD^, HEAD~5, HEAD@{5}, branch~3
file, conflictedfile = filenames (style.css)
remoteref = remote refs (origin)
branchname, currentbranch, targetbranch = a branchname (master)

Resolve merging conflicts faster

git diff HEAD
git diff MERGE_HEAD
git checkout --ours or --theirs conflictedfile

Altering commits

git reset --soft --mixed --hard commit/ref (-- file)
git cherry-pick commit/ref
git revert commit/ref
git rebase currentbranch targetbranch

Altering the latest commit

git commit --amend -m "this will override the last commit"

non-fast forward pushes

git push -f

including untracked files in the stash

git stash --include-untracked

Showing a history of own movements

git reflog branchname

Showing who committed what on a file

git blame file
git blame -L 40,60 file

Better logging and showing things

git log branchname/commit/ref..branchname/commit/ref
git show blobs/trees/tags/commits
git remote show remoteref
git show-ref branchname --abbrev
git show-branch branchname
cat .git/config

Deploying changes from specific commit

git diff --name-only HEAD commit

git pull is NOT the opposite of git push

git push <> git fetch
git pull = git fetch && git merge || git rebase

THE END

thanks!

git@github.com:rob-bar/presentations.git