Popular Git workflows (e.g., rebase-before-merge) have a side effect of destroying important aspects of the history of the branch being merged. Similarly, inexperienced or lazy developers that don't take the time to properly structure commits before pushing or merging can obscure important aspects of the history of the code being developed. Learn what these problems are, and how to avoid them.
4. In my day job, I'm the VP of Technology for Infinity, a small
IT consultancy.
vp, tech
infinity
interactive
4 — LFNW 2017 – 7 May 2017 – @genehack
5. I wanted to give this talk because I love revision control. I've kept my home directory under
revision control for over a decade, I maintain a Perl git wrapper module, and I wrote this thing
called GitGot to automate batch ops across multiple Git repos (but that's a different talk)
i ❤
revision
control5 — LFNW 2017 – 7 May 2017 – @genehack
7. I liked SVN a bit more...
svn7 — LFNW 2017 – 7 May 2017 – @genehack
8. Hell, I even liked RCS
rcs8 — LFNW 2017 – 7 May 2017 – @genehack
9. Actually, that's a lie -- I don't think
anybody liked RCS.
Anybody here remember RCS?
Anybody still using RCS?
rcs9 — LFNW 2017 – 7 May 2017 – @genehack
10. And now we have git
git10 — LFNW 2017 – 7 May 2017 – @genehack
11. I love git. Git makes me happy
i ❤ git
11 — LFNW 2017 – 7 May 2017 – @genehack
12. How many people have used git at least once?
How many people feel comfortable in git?
How many people would call themselves git
"experts"?
quick
poll!
12 — LFNW 2017 – 7 May 2017 – @genehack
13. So, if you're not at least a little familiar with git, this talk is probably not going to that
interesting -- most of the stuff I'm going to talk about does apply to all revision control
systems, but my examples and recommendations are all git-based
what this
talk isn't13 — LFNW 2017 – 7 May 2017 – @genehack
14. I'm also not going to be claiming to dispense any universal
truths in this talk...
nouniversal
truths14 — LFNW 2017 – 7 May 2017 – @genehack
15. I'm not even going to try to convince you that anything I'm telling you is a "best practice".
Pretty much anything I advocate in here, I'm sure people will be able to come up with an
example where I'd say, "yeah, for that, don't do it"
not even
"best
practices"15 — LFNW 2017 – 7 May 2017 – @genehack
16. So what is this talk about then?
what this
talk is16 — LFNW 2017 – 7 May 2017 – @genehack
17. Opinionated commentary on some aspects of using
revision control systems...
some
opinions
17 — LFNW 2017 – 7 May 2017 – @genehack
18. ...based on things I've seen over the past mumble years making
extensive use of revision control on personal, open source, and
commercial software projects
photo modified from http://i2.kym-cdn.com/photos/images/original/
001/044/247/297.png
backed up with
experience
18 — LFNW 2017 – 7 May 2017 – @genehack
19. Some of this stuff may be more important for larger projects
with multi-person teams ...
maybe more
important for
larger projects
19 — LFNW 2017 – 7 May 2017 – @genehack
20. ...but it's also important if you've just started a project that you're thinking might grow into
something bigger. Having a solid project history from the get-go can make it a lot easier
for contributors to come on board and start pitching in
but also good for projects
that aspire to be
bigger20 — LFNW 2017 – 7 May 2017 – @genehack
23. Eventually we're going to talk about how to make better use
of the history in your repos ...
making better
use of history
23 — LFNW 2017 – 7 May 2017 – @genehack
24. ...but first, we're going to talk about ways to make better
history
making
better
history24 — LFNW 2017 – 7 May 2017 – @genehack
25. For all these things, there are a few common elements
prerequisites
25 — LFNW 2017 – 7 May 2017 – @genehack
26. For maximum value, you're going to want to apply them
consistently
consistency
26 — LFNW 2017 – 7 May 2017 – @genehack
27. Make them into habits
habits
27 — LFNW 2017 – 7 May 2017 – @genehack
28. They're pretty much all the type of thing that if you do them
all the time...
do it all
the time28 — LFNW 2017 – 7 May 2017 – @genehack
29. ...you eventually will just do them without thinking too much
about it
then you
don't have
to think
about it29 — LFNW 2017 – 7 May 2017 – @genehack
30. or even better, if you're the right kind of twisted...
even
better30 — LFNW 2017 – 7 May 2017 – @genehack
31. ...you'll automate things. for example, i periodically run some scripts to find repos in a
"dirty" state, or that have local commits that haven't been pushed to a remote, and then
clean them up
automate
it
31 — LFNW 2017 – 7 May 2017 – @genehack
32. so, moving on to how to make better history
how to
make
better
history
32 — LFNW 2017 – 7 May 2017 – @genehack
33. if you're going to talk about git, you almost have to talk about workflows. potentially one
of the more contentious aspects of starting a new project is deciding what your workflow
is going to be
workflows
33 — LFNW 2017 – 7 May 2017 – @genehack
34. workflows can range from the very simple -- just a single branch in
a local-only repo, just adding commits onto the HEAD of that branch
photo credit: modified by https://www.flickr.com/photos/appleboy/
5488984566/in/photostream/
no remote
no branches
master only
34 — LFNW 2017 – 7 May 2017 – @genehack
35. or you can have that basic setup, but with a remote that you push things to every so
often. this is basically the simplest possible branching workflow -- when you have
local commits you haven't pushed to the remote yet, that's (if you squint, a bit) a
branch
photo credit: modified from https://www.flickr.com/photos/appleboy/5488387469/in/
photostream/
local master
no branches
& periodic pushes
35 — LFNW 2017 – 7 May 2017 – @genehack
36. all the way up to fairly complicated workflows like git
flow, where you have multiple branches in flight at any
given point.
anybody using git flow, or anything equivalent?
photo credit: https://www.flickr.com/photos/appleboy/
5488984404/in/photostream/
git flow
36 — LFNW 2017 – 7 May 2017 – @genehack
40. this is basically doing extra work to mimic what a fast
forward merge probably would have done
rebase
before
merge40 — LFNW 2017 – 7 May 2017 – @genehack
128. you can customize
the template for
the commit message
128 — LFNW 2017 – 7 May 2017 – @genehack
129. if you get to this point, you're also going to want to script
the repo setup process
git config --local commit.template ./.template
# edit .template to add whatever you want...
129 — LFNW 2017 – 7 May 2017 – @genehack
151. [color]
branch = auto
diff = auto
grep = auto
interactive = auto
showbranch = auto
status = auto
ui = auto
151 — LFNW 2017 – 7 May 2017 – @genehack
152. [color "status"]
added = green bold
changed = red bold
untracked = cyan bold
152 — LFNW 2017 – 7 May 2017 – @genehack