I have a git repo which compiles into a dist folder and generates a bunch binaries (executables).
The binaries and dist
folders are .gitignore
-ed and hence, are not included in the repo.
But I want to distribute a source
+ binaries
snapshot zipfile.
I want them to contain:
a) all the sources
b) all the binaries
c) the dist folder (so that they can tweak it)
d) not the .git/
directory, not the hidden files like .cache
or node_modules/
etc.
Generate zip archive of a git repository ignoring the files listed in .gitignore
:
git archive -o [email protected] HEAD
- To exclude files and directories from
git archive
, you can also use the.gitattributes
file.-
Create a file named
.gitattributes
in your project root (if it doesn't exist). -
Edit the file: Each exclusion should have a file pattern followed by "export-ignore":
.gitattributes export-ignore .gitignore export-ignore /mytemp export-ignore
-
git-ignore the
.gitattributes
file itself -
Commit the
.gitattributes
file (otherwise,git archive
won't pick up the settings)
-
Then proceed with the natural way of creating a snapshot zip:
git archive -o archive.zip