Git slides

download Git slides

If you can't read please download the document

Transcript of Git slides

git

you won't learn gitin twenty minutes at a LUGbut here are twenty-odd slides anywaysorry there are no pictures

David SpencerBradford Linux Users Group14 September 2015

quick quiz

Who uses it?
or has tried it?
or wants to try it, started reading about it, and got put off?What do we know about it?purpose

history

other similar tools
(has anybody here used other tools?)

what

source code control systemrevolutionised a stale technologypopular, or even trendy
(this was not foreseeable)Github is the new Sourceforge...
Github is the new Linkedin?
Github is the new Blogger?
Github is the new git?

who and why and when

January 2002: Linus doesn't scaleBitkeeper trial
the only suitable software, but proprietaryEarly 2005: terminated amicably but suddenly
Tridge reverse engineered the Bitkeeper protocol
2.6.12-rc2 left high and dryLinus coding binge

I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'Git'

3 April 2005 - started
6 April - announced
7 April - self hosting
11 April - "I don't even know yet.
I'm playing around with my own scripts and tools right now"
18 April - first big Linux merge
29 April - merging Linux at 6.7 patches/sec
16 June - 2.6.12 released
26 July - Linus hands over to Junio Hamano
21 December - git-1.0

design

FastDistributed data store, and distributed workflowScales wellCVS as an example of what not to do
(if in doubt, do the opposite)Really just a name/value data store
(colossal understatement)Strong safeguards against corruption

what's it useful for?
why should we care?

Answering the second question first:
because lots of other people find it usefulAnswering the first question second:
working with other people(and maybe keeping your own stuff tidy)

Use The Source

Command linegit clone http://github.com/darktable-org/darktable.gitnetwork awarereceive a subdirectory 'darktable'contains
(a) the source tree (as if you'd extracted a tarball)
(b) hidden directory .git/ with ALL the metadatabang up to datejust follow the instructions like a tarball

Contribute back

Your 'git clone' is a first class copyYou can modify it and offer the changes back
("pull request", or send email patches)You can push the changes back if authorised
git pushYou can distribute independently (fork)You can receive and merge changes
(from "upstream" ... from anywhere)
git fetch, git merge, git pull

How it works

Initialise a new directory
or existing directory tree or clone.git contains a key-value storeKeys are SHA-1 40 character hex hashes
Values are file deltas
(1) highly efficient to store and restore
(2) cryptographically secureThat doesn't sound like CVS or Visual Studio!
... until you realise ...
(3) file deltas == file history

How it works

Source management commands ("porcelain")
are implemented as key/value store operations ("plumbing")edit edit edit editLooks good?
git add hm, maybe a bit more editing
git add
don't need that any more
git rm Yes that's good
git commit -m 'Description of my changes'

commits

identified by 40 character hex string
(old systems just used increasing revision number)but can be truncated to just first few (7-ish)aliases:
HEAD, tag (release), branchname(just identify a key in the key-value store)you can go back to a commit, diff with a commit, read the message, cherry-pick, format a patch...

branches

Ever had some script that worked well
but you wanted to make some improvements
stuffed it up
wished you could go back?or even have two versions
one stable
the other experimental?This is what branches are for

branches

Ever had multiple people working on different aspects of the same project?Falling over each other's incompatible changes?This also is what branches are forMerging them is tricky
git has lots of handy solutions for thatgit diff, three way diff tools (meld)
git merge, git rebase

history

Who made these changes and when?
git log
git blameIt used to work, what change introduced this bug?
git bisect

history

cryptographically secure
=> history cannot be falsified
=> can be rewritten (quick quiz)
=> anyone with old history will experience pain
(quick quiz)Once you publish your commits
don't rewrite history
not ever ... srslygit commit --amend

Github

Uses:
Sourceforge without the smell of death
and client-side tooAbuses?
blogs, articlesControversies
China, DMCAAlternatives
Atlassian Bitbucket https://bitbucket.org/

weird uses

etckeepersaving gamesmore?

crappiness

git extensions (mostly crap)git graphical interfaces (mostly crap)
Not crap: github, cgitmerge conflicts in the middle of a rebase
JUST FORGET THAT CRAP DAMN YOU crappy people who don't do releases
Learn how to use git tag, srslyprojects still using other crap
svn mercurial bzr ...people who tell people they are doing git wrong
gitflow == follow my crap rules, you'll feel secure and I'll feel important

learning

Vast amount of tutorials, mostly crapAnnoying diagrams of commits and branchesAnnoying terminology (index, staging)Command line inconsistenciesGit manpages ok-ishGithub help is crapLearn by doing (doesn't work for scary stuff)
https://try.github.io/levels/1/challenges/1

learning

Worked tutorials
https://try.github.io/
http://rogerdudler.github.io/git-guide/Pro Git (book)
https://git-scm.com/book/en/v2Git from the bottom up
http://ftp.newartisans.com/pub/git.from.bottom.up.pdfManpages
https://git-scm.com/docs and man git-thing
https://training.github.com/kit/downloads/github-git-cheat-sheet.pdfSo you have a mess on your hands
http://justinhileman.info/article/git-pretty/git-pretty.pdf

learning

Linus on YouTube (2007, long)
https://www.youtube.com/watch?v=4XpnKHJAok8Linus on YouTube (2009, even longer)
https://www.youtube.com/watch?v=8ET_gl1qAZ0Adolf on YouTube (1945, very short)
https://www.youtube.com/watch?v=CDeG4S-mJts

some new words we learned today

repositorycommit, historybranch, fork, clone, tagHEADmasterindex, working treefetch, merge, pull, pushpatch

questions?experiences?