2

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? :)

Greg
  • 2,413
  • 5
  • 22
  • 23

1 Answers1

1

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

alvar
  • 11
  • 2
  • The ideal solution for me would be as a part of git archive (like --verbose). I only need that information when I actually run the git archive command, and I don't want to have the repo available really. As for --archive-comment, I can't seem to be able to find such option available in git archive command :) – Greg Feb 05 '14 at 12:47
  • I do not understand the problem then... When running `git archive` you have access to the repository, so you may as well do `git log -1`? `--archive-commment` is not an option of **git** archive but of **zip** – alvar Feb 05 '14 at 13:37
  • Sorry for the confusion - git archive is in fact pulling data from remote repository into a temporary location, where git repository does not exist, so I suppose if git log can retrieve comment from remote repository without the need of being cloned this would work for me. – Greg Feb 05 '14 at 13:54
  • In fact your suggestion of using git log led me to this link (http://stackoverflow.com/questions/20055398/is-it-possible-to-get-commit-logs-messages-of-a-remote-git-repo-without-git-clon), which answers my question really – Greg Feb 05 '14 at 13:57