Skip to content

Instantly share code, notes, and snippets.

@avar
Last active December 11, 2015 05:28
Show Gist options
  • Save avar/4552070 to your computer and use it in GitHub Desktop.
Save avar/4552070 to your computer and use it in GitHub Desktop.
A scratchpad for topics I'm covering in Git training.

-*- org -*-

Git Training

Topics to cover

Remember

Give the audience time to see the command-line fu

Explain stuff before you do it

Use ^SHIFT+L to clear the screen before the next example

Basic configuration

color.ui=auto

push.default=tracking

pull.rebase=true

setting up __git_ps1

Using branches

Shit, I wish this was on a branch: git branch -m

Creating new branches

Setting them to track upstream

Pushing branches to upstream & deleting them

Stashes

Cover why you’d use stashes & why you’d use branches

Seeing what you’re about to push

git push -n -> do log on the line it shows you

Finding stuff

Commits

Finding commits by content

git log -p -Sstring
git log -p -Gregex
git log –reverse -p -SPlack –full-diff – lib

Files

git-ls-files

Content: git-grep

Like grep/ack but fasterer

git grep -P ‘pcre regex’ (‘foo(?!bar)’ or !foo(?=bar)’)

git grep <GNU grep option>

Bisecting

git bisect

git bisect start

git bisect [<bad> [<good>…] – [<paths>…]

Reverting commits

Reverts are just reverse cherry-picks

Show how to revert the correct side of a merge

Rebase

git rebase

The Index

git add -p

git reset -p

Referring to commits

git-rev-parse -> show all the tricky bits of syntax it has

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment