Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git workshop for dum^Wstudents

Git workshop for dum^Wstudents

A Git workshop I ran at University of Turku

Jyrki Pulliainen

November 22, 2011
Tweet

More Decks by Jyrki Pulliainen

Other Decks in Technology

Transcript

  1. Cons of CVCS • Offline access to single revision •

    Usually commits, merges etc not possible offline • Expensive operations (merge, branch, commit) • Single point of failure in the system
  2. Distributed version control • New kid on the block... •

    ... except it's old (monotone, bitkeeper etc) • Full history on everyone • No need for a central server... • ...but you can have a one • DVCS: git, mercurial, monotone, bitkeeper, bazaar (and the list goes on...)
  3. Pros of DVCS • Enables working offline • Workflow is

    free • Cheap operations • Full history available at everyone • History can be edited! • No single point of failure!
  4. Cons of DVCS • "Network" can get messy • Initial

    clones (containing full history) can be big • Independent work creates conflicts and merges
  5. • Originally developed by Linus Torvalds for Linux kernel development

    • Now maintained by Junio C Hamano • Replaced bitkeeper in kernel development • Development started in 2005 • Now in version 1.7.7 Brief history
  6. blob tree + filename + mode subdir + parents commit

    + parents + message branch HEAD ref:
  7. Roles of the trees • HEAD: Last commit, next parent

    • Index: Proposed next commit • Working dir: Sandbox
  8. Branching & Merging • Branches are just labels on commits

    • Merge is just a commit with two or more parents • Remote branch is just a speacially named branch: remote/<remotename>/<branchname>
  9. • clone: Clone a remote repository • Supported protocols: SSH,

    git, http, https, ... • fetch: Fetch remote references • pull: fetch + merge • push: push to remote server Working w/ others
  10. Capitalized, short (50 chars or less) summary More detailed explanatory

    text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. Write your commit message in the present tense: "Fix bug" and not "Fixed bug." This convention matches up with commit messages generated by commands like git merge and git revert. Further paragraphs come after blank lines. - Bullet points are okay, too - Typically a hyphen or asterisk is used for the bullet, preceded by a single space, with blank lines in between, but conventions vary here - Use a hanging indent A good commit message
  11. • The Best Ever(tm) feature in version control systems •

    Keeps history clean and working • Makes you look like a superb rockstar dev • Can be undoed (locally)! History editing
  12. History editing: caveats • Branches might get "out of sync"

    • May require a forced push... • ...but never ever ever force push to a branch someone else is also using! • Never. • Ever.
  13. History-editing-fu • git commit --amend • git rebase • git

    rebase --interactive • Not for the faint hearted: git filter-branch
  14. • Can recover from nearly everything • Can not save

    from accidental: ◦ git checkout -- somefile.txt ◦ git reset --hard ◦ git gc • Learn to use and it'll serve you well! git reflog