As title suggest, I want to know if there is a single git command that put all my project in one folder first (not including .gitignored files) and then proceed archiving the folderâ leaving ignored files not included when archiving which is nice.
This can be beneficial for me as I am working on WordPress plugin with multiple release. Some references.
It is possible in one command provided you define an alias but this isn’t git-related:
you can:
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.
tar -cvjf dist/archive-name.tbz2 --transform='s,^,archive-name/,' $(git ls-tree --full-tree -r --name-only --full-name HEAD)
git reset --hard
to restore without any of the changes you made in step #2.Hints:
--transform='s,^,archive-name/,' is so your files will be extracted to
archive-name/….`, you can remove it if you don’t need that.