Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git archive from changed files on bare repos

Tags:

git

diff

archive

I have a remote bare repository (no working dir) that creates install-tars. Works nice. But now I want to create tars only of the changed files. I tried it this way:

git archive --format=tar --prefix='/' HEAD `git diff V1.02 --name-only` | gzip -9 > ~/tars/update-v1.02-`git describe master --tags`.tar.gz

This works great with my local repository. It creates a tar with the files from tagged version V1.02 to the latest commit. But it doesn't work with bare reposities. Is there another solution?

like image 530
Andree Wendel Avatar asked Nov 12 '22 20:11

Andree Wendel


1 Answers

The two commit form of git diff will work in a bare repository (git diff [options] <commit> <commit> [--] [<path>...]).

The following should do what I understand you want:

git archive --format=tar --prefix='/' master `git diff V1.02 master --name-only` | gzip -9 > ~/tars/update-v1.02-`git describe master --tags`.tar.gz

I also suggest changing the HEAD from your original command to master (as shown above) to be consistent with the rest of the command, and be resilient if someone changes which branch HEAD points to (alternatively replacing all occurrences of master with HEAD in the example above).

like image 69
Jacob Helwig Avatar answered Nov 15 '22 23:11

Jacob Helwig