Greg
Greg

Reputation: 2493

git archive with last commit message - why is this not possible? or is it?

I don't seem to be able to find the answer for what I believe should be simple task.

Consider the following - I have git archive command to pull content from git repository, and I wanted to be able to display commit message associated with it, but I'm not sure why this is not possible?

I know I could in theory do git clone and then do git status, but at the moment this is my last resort and I'd like to know if I can achieve this with git archive only. I can add --verbose switch and it lists all the files to be archived, which is ok, but what I wanted really is to display the commit message.

Are there any tips apart from reading through git help archive? Also, if it's not possible currently, would such feature be useful to people or do I just want too much? :)

Upvotes: 2

Views: 483

Answers (1)

alvar
alvar

Reputation: 11

git archive will generate a tar or zip of the files. Wherever you unfold it, you no longer have a git repo, but just a working dir. So first thing you need to decide is where you would like to have your message...

If you are using a zip file, you may add it to the zip as an archive comment with the --archive-comment flag. If you use a tar, I think you can only put it in the name of the tar file or the name of a newly-created file added to the tar (or the contents of a newly created file added to the tar).

You can extract the message subject, for example, with git log -1 --format=format:'%s', or with git log -1 --format=format:'%f' if you will use it as a file name. (see git log --help for other options).

Upvotes: 1

Related Questions