Git for ages 4 and up

Radim Klaška

Morpht.com & Drupal.cz

Git for ages 4 and up

Michael G. Schwern

Linux.conf.au 2013

Who are you?

I've seen git

  • github.com
  • cgit.drupalcode.org
  • Looked at older versions

I've used git

  • maybe used some GUI
  • got the code
  • made changes
  • commited changes
  • shared them with coworkers

I fixed a problem

  • helped others
  • resolved git conflict
  • worked with multiple remotes
  • probably prefer CLI

Why is it so compliacted

  • written by Linus Torvalds in 3 weeks
  • then maintained also by other Linux kernel developers
  • you need to understand the internals
  • really good and simple

These should sound familiar

init

clone

 

add

commit

 

branch

merge

status

diff

log

 

checkout

 

pull

push

Shortcuts

radimklaska@rku:~ $ cat ~/.gitconfig 
[user]
	name = Radim Klaska
	email = radim@klaska.net
[push]
	default = simple
[alias]
	st = status
	co = checkout
	mr = "merge --no-ff"
	un = "reset --soft HEAD~"
	unn = "reset --hard HEAD"
	lg = "log --graph --full-history --all
              --pretty=format:'%C(yellow)%h %Cgreen%cd
              %Creset - %C(auto)%d%Creset %s %C(cyan)
              [%aN %C(yellow)%ae%C(cyan)]%Creset'
              --date=format:'%Y-%m-%d %H:%M:%S'"

New repo

git init

git add

git commit

Second commit

Get existing repo

git clone [address]

Seems simple

but we've seen a lot

Complete repo

Binary objects (files)

Staging area

  • = "index"
  • = "cache"

Commit object

  • commit id (= check sum)
  • check sum - depends on content
  • contains things like
    • references to "files"
    • references to parent commits
    • info about author
    • log
    • timestamps
  • every id is unique

Reference

  • HEAD
  • master

What does it mean?

History

Branching

Done. Simple.

git checkout

Merging

Fast forward merge

Merging

the dark side

Merge conflicts

Conflict resolved

Also, not a fast forward merge

--no-ff

Remotes

Remotes

Keep your fork up to date

Tips

Simple workflow

Oh shit git!

Time traveling is fun

(alone)

Remotes & team workflow

Next time ;-)

Where to go next

Advanced GIT for Developers

by Lorna Jane Mitchell

Advanced Git:
Graphs, Hashes, and Compression, Oh My!
by Matthew McCullough

Questions?

Thank you!

Git for ages 4 and up

By Radim Klaška

Git for ages 4 and up

  • 2,096