macOS click-and-point file and folder archiving is limited. Often when I need to archive a code project folder that has GIT version control files and other assets I do not want to be zipped. For such a task click-and-point falls short but the command line gets the job done.
To ignore files and folder when creating a zip archive using the command line add the -x flag followed by a filter. For example, to ignore .git VCS and the macOS .DS_Store files run the following command using the terminal.
zip -r Archive.zip ~/folder-location -x "*.git*" -x "*.DS_Store"
If you are creating zip archives frequently add a bash function to your .bash_profile file.
function zip_clean() {
zip -r $1 $2 -x "*.git*" -x "*.DS_Store"
}
With this function you can run the follow command for the same result.
zip_clean Archive.zip ~/folder-location
Having a bash function is helpful especially if you have a long list of files you want to be ignored.
Leave a Reply