Conversation

So fricking annoying that git doesn't support `git archive` to a directory

3
0
0

@mcc would git clone with a local reference do that?

1
0
0

@r0k i don't want to clone. i mean yes it would work but it would be about as inconvenient as creating a zip, either i create a zip and then i throw away the .zip or i create a clone and i throw away the .git

2
0
0

@mcc @r0k seems like a a git worktree would be close to this...?

(it's not 100% there because ".git" still exists, but it exists as a small plain text file rather than a directory.)

0
0
0

@mcc @r0k git filter-repo --subdirectory-filter my-archived-project ?

0
0
0

@mcc you mean copying out the current repo state into a directory someplace else? Do you mean like this?

https://github.com/git/git/blob/master/Documentation/git-archive.adoc?plain=1#L190-L194

1
0
0

@mcc @gnomon I was gonna suggest this direction (pipe to archive-extraction command) before squinting harder at the examples section and going "ah. they thought of that already!"

As to why that isn't a built-in option…yeaaaa…

TBF: I'd literally not even heard of `git archive` before today so maybe it doesn't get a lot of love?

1
0
0

@bitprophet @mcc `git archive` is pretty often used to by projects I follow to create release archives in a repeatable way. The export-ignore and export-subst facilities¹ offer hooks and tooling to streamline this use case. I think git-archive does get care and polish to support the specific use cases it's currently aimed to fulfill, but it's not a long list, and perhaps the docs focus more on how the features work than why they were created.

¹: https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes#_exporting_your_repository

1
0
0

@gnomon @bitprophet one thing I do feel is missing versus the mercurial equivalent is a dotfile documenting which hash it was built from

2
0
0

@mcc @bitprophet I think that's what the export-subst feature provides in the link above? That's how I've used it, anyhow. I agree it would be nicer if that feature were built in and named rather than provided as a bucket of tools though.

(edit: lol there's a markup error in the Pro Git 2nd. Ed. book at that link in the final example of the export-subst section! Right, filing a pull request to fix that up.)

0
0
0

@wjt @gnomon @bitprophet I did not know this, I don't use git. Actually I'm still not entirely sure I understand it

0
0
0

@mcc It writes to stdout, so you can just pipe it to tar to extract it into a directory. git archive --format tar HEAD | tar -xC outputdir

0
0
0