Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3423188
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:19:31+00:00 2026-05-18T06:19:31+00:00

I’m in a position where I’d like, when I export a subdirectory of my

  • 0

I’m in a position where I’d like, when I export a subdirectory of my git repository, to have the full hash of the commit being archived inserted into a given file. The reason for this is that I ship this code (a subdirectory of a repository too large to conveniently regularly export) to my customer, who then builds it (outside of the git environment), and we want to be able to tell from the logs which version of the code generated it, to aid debugging.

The solution appears as if it should be to add the file to .gitattributes with the export-subst attribute, and have the %H token replaced with the has when git archive is run. I’m not seeing this behaviour, however.

I’ve been using the a page on the Pro Git book as a reference (see here), but trying to adapt it for use with a subdirectory rather than the root of the repository.

The directory I’m trying to export is called iDevice. I’ve created a file under that folder called hash_test, which contains the text Last commit date: $Format:%cd$.

When I run git archive --format=tar HEAD:iDevice/ | gzip > test.tar.gz, the file is not modified. When I run git archive --format=tar HEAD | gzip > test.tar.gz the file is modified.

I have tried keeping the .gitattributes file in the root of my git directory, and in both the root and subdirectories. I’ve tried referencing the file as both iDevice/hash_test and hash_test in the .gitattributes file (as I thought it may be something similar to a bug I saw listed on kerneltrap.org where using –prefix= confused the archive command – the URL ends /mailarchive/git/2008/4/8/1378004 which I’d link to properly but I don’t have the reputation to post more links…). None of this has helped, however.

Any suggestions would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:19:32+00:00Added an answer on May 18, 2026 at 6:19 am

    Attributes for git-archive are taken from the tree which is being archived. This means that:

    • For git archive ... HEAD:iDevice the attributes must be in iDevice, or they can’t possibly be seen. (I assume this is supported; I’ve never tried it.)

    • You must have committed your gitattributes file. Whatever’s in the worktree is irrelevant, unless you use the --worktree-attributes option to git-archive.

    And a suggestion which may bypass all of this: use git archive ... HEAD iDevice, not git archive HEAD:iDevice. The command supports <tree-ish> <path> arguments; no need to specify a tree object directly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.