For each commit hash use git show

I need to log all my git posts for my teacher. He gave me the following example:

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

      

I know the "you" part is supposed to be my name, and the git command works fine, but after it comes back, it is more iconic and doesn't do anything. I also understand that it has to use every commit hash for a command git show

. Any suggestions? I am also using OSX.

+3


source to share


3 answers


Perhaps because you need to tell the shell that the command line will continue on the following lines (with a trailing one \

):



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

      

0


source


VonC's answer is correct with regard to handling newlines, but your initial approach complicates things. You can use git log -p

instead of a combination of git log

and git show

:



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

      

+1


source


Instead of using a while loop, you can run

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

      

0


source







All Articles