如何打印最后一次提交的信息在一个Git仓库的每个文件 [英] How print last commit info for every file in a git repository

查看:107
本文介绍了如何打印最后一次提交的信息在一个Git仓库的每个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,复制的远程服务器上,从我的Git仓库的一些文件。
对于每一个被复制的文件,如果是版本控制之下,我想生成一个线,如:

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 line, like:

Filename: <filename>, commit: <last-commit-hash>, date: <date of last commit>

的想法是在文件中存储这些行并复制它,以及在远程服务器上。这样,我总是可以知道哪个服务器上的文件属于哪个犯我的git仓库。
是否有一个快速的方法来做到这一点?

The idea is to store these lines in a file and copy it as well on the remote server. This way I can always know which file on the server belongs to which commit on my git repository. Is there a quick way to do that?

推荐答案

我是持怀疑态度多么有用,这将是,因为你总是可以从本地存储库获取信息,或通过GitWeb里,但在这里你有:

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

%H 为您提供了一个简短的哈希值;如果你想充分,可以用%H 。 // git的供应链管理:ISO | | | RFC短(请参阅的日期格式拨弄.COM /文档/混帐日志>混帐日志手册页)。

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).

这篇关于如何打印最后一次提交的信息在一个Git仓库的每个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆