对于每个提交哈希使用 git show

For each commit hash use git show

我需要为我的老师记录我所有的 git 提交。他给了我下面的例子:

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

我知道 "you" 部分需要是我的名字并且 git 命令工作正常但是在管道之后它 returns 有一个大于号并且没有做任何事物。我也明白它应该为 git show 命令使用每个提交哈希。有什么建议么?我也在使用 OSX.

可能是因为您需要指示 shell 命令行在下一行继续(尾随 \):

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

VonC 在处理换行符方面的回答是正确的,但是您最初的方法过于复杂了。您可以使用 git log -p 而不是 git loggit show 的组合:

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

您可以 运行

而不是使用 while 循环
git log --author=you --patch --stat > log.txt