-
-
Save LeonardoCardoso/6c083b90a8c327d8c82f to your computer and use it in GitHub Desktop.
#... | |
function gitzip() { | |
git archive -o $@.zip HEAD | |
} | |
#... gitzip ZIPPED_FILE_NAME |
Good point. I actually want to accomplish exactly what the title says. I'm using a .gitignore file simply because it has a preselected list of items to ignore. There would be no commits in this repo.
If you require the files in the archive to be nested within the repo folder, and not in the root of the zip ie:
Not:
[
file1
file2
...
]
But:
[
repo-folder
[
file1
file2
...
]
]
Use something like this -
git archive --prefix ${PWD##*/}/ HEAD -o ../${PWD##*/}.zip
Thank you very mutch, it's very helped
if you find it useful to include the time of the backup/archive:
sudo git archive --prefix ${PWD##*/}/ HEAD -o ../${PWD##*/}-$(date "+%Y.%m.%d-%H.%M.%S").zip
@sadernalwis That's a good idea.
I use one time
git config --global alias.zip 'archive HEAD -o'
and then when you want..
git zip test.zip
Ah sorry repost, sorry..
used this one for windows Powershell:
git archive HEAD -o ../$(Split-Path -Path ${PWD} -Leaf)-$(Get-Date -UFormat "%Y.%m.%d-%H.%M").zip
I got here when i looked for a command do backup the whole (local) repository including .git.
Here it is:
7z.exe a -bd ../archive.7z * '-xr@.\.gitignore'
Based on this answer: https://superuser.com/questions/28162/how-do-i-use-7-zip-to-backup-files-but-exclude-some-directories
Err,
HEAD
includes local commits, but not files / changes in the working directory that haven't been committed locally.Notice that
foo.txt
is in the archive, butbar.txt
is missing because it hasn't been committed.