Created
January 18, 2012 04:17
-
-
Save FGtatsuro/1630925 to your computer and use it in GitHub Desktop.
Gitでn番目のコミットハッシュを取得するワンライナー ref: http://qiita.com/items/1776
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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