Git Archive but first put all the files inside a folder then start archiving
I want all the files (minus the
.gitignored
files) move to a folder first then proceed archiving that folder
It is possible in one command provided you define an alias but this isn't git-related:
you can:
- clone your repo elsewhere (that way you don't get any ignored or private file)
- move your files as you see fit in that local clone
- archive (
tar cpvf yourArchive.tar yourFolder
)
But git archive
alone won't help you move those files, which is why I would recommend a script with custom bash commands (not git commands).
You don't really need to copy / clone the repo anywhere.
- Make sure you committed all your changes.
- Process the files any way you want.
- Run
tar -cvjf dist/archive-name.tbz2 --transform='s,^,archive-name/,' $(git ls-tree --full-tree -r --name-only --full-name HEAD)
- run
git reset --hard
to restore without any of the changes you made in step #2.
Hints:
- The
--transform='s,^,archive-name/,' is so your files will be extracted to
archive-name/....`, you can remove it if you don't need that.