Skip to content

Instantly share code, notes, and snippets.

@southgate
Created April 24, 2014 11:07
Show Gist options
  • Save southgate/11250571 to your computer and use it in GitHub Desktop.
Save southgate/11250571 to your computer and use it in GitHub Desktop.
Training Guide

Copy all github.com/southgate/dotfiles/tree/master/gitconfig?

autocrlf false | true | input

Rebase

githubtraining/example-branches create a feature-1 branch make a couple commits checkout master make a commit rebase feature-1 onto master

rebase interactive

Reset

reset --hard => reset branch to given ref, clean out the index, clean working directory reset --mixed => reset branch to given ref, clean out the index, leave working directory reset --soft => reset branch to given ref, leave staging in tact, leave working directory in tact

Reflog

Each time a branch is updated to point to a new reference. Defaults to 90 days.

$ git reflog
$ git reflog --all
$ git config --global alias.undo "reset HEAD@{1}"
$ git undo 
$ git undo
$ git checkout HEAD@{1}

Cherry-pick

  • Cherry pick a commit from a feature branch $ git cherry -v master $ git cherry -v $ git cherry -v

Bisect

githubtraining/example-bisect

Get bisect setup on Matt's machine Set JAVA_HOME run mvn test

Remote

  • Explain convention of origin
  • Aliasing, bookmark to server URL
  • Removing connections

Rerere

reuse recorded resolution

  • Create a branch and a feature with a conflicting commit on them each.
  • git config --global rerere.enabled true
  • git merge master
  • Resolve conflict
  • revert merge
  • add another commit.
  • git merge master
  • not resolved conflict

Suprisig: not portable:

the .git/rr-cache folder.

Hot Tips

r1..r2 commits reachable from r2 that aren't reachable from r1

r1...r2 commits on one or the other but not both

Refspec

+source:destination

Searching

$ git log --author Matthew $ git log --since 2.days.ago $ git log -S myvar $ git log --grep=Fix $ git log --follow --stat --diff-filter=A --

Submodule

$ git submodule add https://github.com/southgate/a-great-lib.git

$ git status $ git diff --cached $ cat submodule is a project at a commmit

  • make a change in a-great-lib

  • commit change

  • got to other repo instance and fetch / merge origin/master

  • change is just a commit version change $ git submodule update

  • Issue with un-pushed change to server

  • make a lib change, don't push

  • commit submodule change in superproject

  • got to other repo

  • git pull $ git submodule update # should fail $ git log -l

Issues:

  • works in detached head so you can easily trounce your work if git submodule update

  • there are some issues but it's workable

Workshop Layout

  • git version (1.8)
  • It's okay to be taking notes
  • Chat on laptop screen
  • Two different browser
    • Chrome - One as a githubteacher / abc123
    • Firefox - One as a githubstudent / abc123
  • Two different terminal profiles
    • Light - student
    • Dark - teacher
  • Slide decks - matches workbooks
  • Google Hangout with Mic?
  • Mouseposé
  • Personal Access Token?
  • Logging in with
  • Skitch to explain bisect
  • Plenty of breathing room while stuff happens
  • Create a list of today's objectives
    • bisect
    • etc.
    • student extras
  • If there's something we don't know => we can have training team to do something
  • SlideDeck gotcha
    • Harder to do both sections
  • Create our own layout
  • github/training-kit/blob/master/slides/ <= slides for intermediate-advanced
  • Live deploy

Things to beef up on

  • reflog
  • checkout as a multi-use command
  • remote (origin as convention)
  • HEAD
  • merge vs commit (merge --no-ff)
  • checkout --ours vs --theirs
  • just git fetch to do a selective merge
  • git reset --hard|soft|mixed
  • git stash
  • setup some shortcuts
  • Git 2.0?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment