Skip to content

Instantly share code, notes, and snippets.

@randomecho
Last active October 13, 2015 18:58
Show Gist options
  • Save randomecho/4241448 to your computer and use it in GitHub Desktop.
Save randomecho/4241448 to your computer and use it in GitHub Desktop.
bagged dipping dots of git commands and config settings

[alias].gitconfig

quick search of commit messages (and showing hash) with certain word

search = !sh -c 'git log --grep=$1 --pretty=format:\"%h%C(bold yellow) %s%C(reset)\"' -
$ git search wax // e.g. list out all commits that contain "wax" in message

export last X commits showing just commit message and files touched

whatup = !sh -c 'git whatchanged --pretty=format:%n%s --name-only -$1 > /w/logs/git.log' -
$ git whatup 3 // e.g. export out list of last three commit messages and files touched

dump out commits with SHA-1, date made and simple graph of branching → From Git Immersion

hist = log --pretty=format:\"%h %ad | %s%d\" --graph --date=short
$ git hist // e.g.

undo last commit, unshove those files back onto the stage

undo = reset --soft HEAD~

[color "status"].gitconfig

changed = bold yellow
untracked = bold cyan
added = bold green

Keep in step with original repo regularly, get own fork up to date before working

Because working with old files is a world of mess. → Pinched from ThinkUp docs

$ git remote add zero git://...      // adds new upstream of the original
$ git checkout master                // or whatever branch we want to rebase from
$ git fetch zero                     // yank it down from the master upstream
$ git rebase zero/master             // spackle it like a champ
$ git checkout copyedits             // topic branch we want to fidaddle in
$ git rebase master                  // rush the forward line to current commits before whistle

Only grab a single branch from remote repo, not the whole suitcase

No need to slurp all 20 topic branches when you just want to keep up to date with the master. → Out of the loins of How to clone a single branch in git? - Stack Overflow

$ mkdir <repo>
$ cd <repo>
$ git init
$ git remote add -t <branch> -f origin <remote-repo>
$ git checkout <branch>

Commit messages on GitHub

69 characters - max length of commit log on github before clipping
abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0123456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment