How print last commit info for every file in a git repository

前端 未结 3 1469
深忆病人
深忆病人 2020-12-28 18:05

I have a script that copies some files from a git repository of mine on a remote server. For every file that is copied, if it is under version control, I want to generate a

3条回答
  •  Happy的楠姐
    2020-12-28 18:52

    I'm dubious about how useful this will be, since you can always get the information from a local repository, or through gitweb, but here you are:

    git ls-files | while read file; do git log -n 1 --pretty="Filename: $file, commit: %h, date: %ad" -- $file; done
    

    The %h gives you an abbreviated hash; if you want the full one, use %H. You can also fiddle with the format of the date using --date=local|iso|rfc|short (see the git-log manpage).

提交回复
热议问题