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>
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?
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:
The
%hgives 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).