Advanced git features

22
advanced™ git features and how to survive vim

description

Some useful git fu I put together for a talk targeting my co-workers

Transcript of Advanced git features

Page 1: Advanced git features

advanced™ git features and how to survive vim

Page 2: Advanced git features

advanced™ git features and how to survive vim

git makes it

insanely hard too lose

code

Page 3: Advanced git features

every commit is a full snapshot!

No deltas – for fuck sake

Page 4: Advanced git features

A branch is nothing more than a name for a specific

commit

Page 5: Advanced git features

the HEAD is just a pointer to where your working

directory should currently be on

Page 6: Advanced git features

the reflog is a history of all movements of the HEAD

Page 7: Advanced git features

commits in the reflog that are not reachable by any branch will be gc‘ed after

30 days

Page 8: Advanced git features

Noticed you

are on the

wrong branch?

Page 9: Advanced git features

git checkout –b newBranchgit checkout previousBranchgit reset –hard lastValidCommit

git got your back!

Page 10: Advanced git features

git checkout –b newBranchgit checkout previousBranchgit reset –hard HEAD~1

..or relative

Page 11: Advanced git features

Page 12: Advanced git features

commit early & often

yet nobody want‘s to read this!

Page 13: Advanced git features

git rebase –i 6f50a39~1

this is what people should see

Page 14: Advanced git features

Need the lastfive commits

from branch <foo>without merging any previous commits?

Page 15: Advanced git features

git cherry-pick first~..last

Page 16: Advanced git features

avoid unnecessary merges

Page 17: Advanced git features

use a rebase workflow

because

Page 18: Advanced git features

Face it, here is what happens if you merge blindly

- your history becomes a mess- you hide information in merge commits- harder to do git bisect- harder to do cherry-picking

Page 19: Advanced git features

Face it, here is what happens if you merge blindly

- your history becomes a mess- you hide information in merge commits- harder to do git bisect- harder to do cherry-picking

Page 20: Advanced git features

make the console your friend

//commit ALL THE THINGS for fuck sake!git config --global alias.ca '!git add -A && git commit'

//we don‘t need a gui log! git config --global alias.lg 'log --pretty=oneline --abbrev-commit --graph --decorate'

Page 21: Advanced git features

Useful links!

http://www.randyfay.com/node/91http://stackoverflow.com/questions/457927/git-workflow-and-rebase-vs-merge-questions

Page 22: Advanced git features

Get in touch.

http://twitter.com/cburgdorfhttps://github.com/cburgdorf