2015-05-24 31 views
3

我需要记录我的老师的所有我的git提交。他给了我下面的例子:对于每个提交散列使用git显示

git log --pretty="%H" --author=you | while read commit_hash 
            do git show $commit_hash 
            done > log.txt 

我知道“你”部分需要我的名字和Git的命令工作正常,但管后,用大于号返回,并没有做任何事情。我也明白它应该使用git show命令的每个提交散列。有什么建议么?我也在使用OSX。

回答

0

可能是因为你需要指出的是,命令行继续在下线(与尾随\)外壳:在

git log --pretty="%H" --author=you | while read commit_hash \ 
            do git show $commit_hash \ 
            done > log.tx 
+0

难道不应该由一个行中键入它只是工作? –

+1

@AdrianZ。为此,您需要';',例如:'while read commit_hash;做git show $ commit_hash; done> log.tx'(http://www.cyberciti.biz/faq/linux-unix-bash-for-loop-one-line-command/) – VonC

+0

谢谢。这工作完美。重新学习新的东西。 –

1

VonC的答案是有关于处理换行符正确的,但你最初的方法事情复杂化。您可以使用git log -p代替git loggit show组合:

git log -p --author=you > log.txt 
+0

它返回空。 –

+0

@AdrianZ。忘记了'log'和'show'处理缺少的提交规范参数的区别。看到我编辑的答案。 – Mureinik

0

而不是使用while循环,你可以运行

git log --author=you --patch --stat > log.txt