Skip to content

Instantly share code, notes, and snippets.

@FGtatsuro
Created January 18, 2012 04:17
Show Gist options
  • Save FGtatsuro/1630925 to your computer and use it in GitHub Desktop.
Save FGtatsuro/1630925 to your computer and use it in GitHub Desktop.
Gitでn番目のコミットハッシュを取得するワンライナー ref: http://qiita.com/items/1776
python -c "n = 1; import re ;from subprocess import Popen, PIPE;import sys; sys.stdout.write([commit.split(' ')[1] for commit in re.split('\n*', Popen(['git', 'log'], stdout=PIPE).communicate()[0]) if commit.startswith('commit ')][n])" | pbcopy
git log | python -c "import sys; word = 'commit '; n = 0; p = lambda x: sys.stdout.write(x); l = [line.replace(word, '') for line in sys.stdin if line.startswith(word)]; p(l[n])" | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment