How do I zip up a folder but exclude the .git subfolder












167















I'm trying to create a zip file from a folder and I'd like to exclude the .git sub-folder from the resulting zip file.



I have gone to the parent folder of the one I want to zip (called bitvolution) and I'm doing:



zip -r bitvolution.zip bitvolution -x ".git"


But it doesn't exclude the .git sub-folder.



I've tried various combinations, -x .git*, -x .git/*, -x .git/*, -x .git/*. I've also tried using the full path for the exclude argument... but just didn't get there.










share|improve this question



























    167















    I'm trying to create a zip file from a folder and I'd like to exclude the .git sub-folder from the resulting zip file.



    I have gone to the parent folder of the one I want to zip (called bitvolution) and I'm doing:



    zip -r bitvolution.zip bitvolution -x ".git"


    But it doesn't exclude the .git sub-folder.



    I've tried various combinations, -x .git*, -x .git/*, -x .git/*, -x .git/*. I've also tried using the full path for the exclude argument... but just didn't get there.










    share|improve this question

























      167












      167








      167


      48






      I'm trying to create a zip file from a folder and I'd like to exclude the .git sub-folder from the resulting zip file.



      I have gone to the parent folder of the one I want to zip (called bitvolution) and I'm doing:



      zip -r bitvolution.zip bitvolution -x ".git"


      But it doesn't exclude the .git sub-folder.



      I've tried various combinations, -x .git*, -x .git/*, -x .git/*, -x .git/*. I've also tried using the full path for the exclude argument... but just didn't get there.










      share|improve this question














      I'm trying to create a zip file from a folder and I'd like to exclude the .git sub-folder from the resulting zip file.



      I have gone to the parent folder of the one I want to zip (called bitvolution) and I'm doing:



      zip -r bitvolution.zip bitvolution -x ".git"


      But it doesn't exclude the .git sub-folder.



      I've tried various combinations, -x .git*, -x .git/*, -x .git/*, -x .git/*. I've also tried using the full path for the exclude argument... but just didn't get there.







      zip






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 28 '11 at 20:38









      TomTom

      2,26242023




      2,26242023






















          5 Answers
          5






          active

          oldest

          votes


















          203














          The correct expression is -x *.git*, so the full command should be:



          zip -r bitvolution.zip bitvolution -x *.git*


          An explanation from http://selfsolved.com/problems/zip-command-exclude-svn-director:




          The correct incantation is



          zip -9 -r --exclude=*.svn*  foo.zip [directory-to-compress]


          You can also add a
          --exclude=*.DS_Store* to exclude the annoying Mac OS X directory display metadata files.



          Notice that the expression passed to --exclude is using the entire original relative directory path as the original string to match against. So .svn/* by itself doesn't work; the wildcard character in front ensures that it matches .svn directories anywhere in the directory tree.







          share|improve this answer



















          • 12





            I had to wrap the glob in quotes or escape the asterisks with backslashes, like zip --exclude '*.git*' -r directory.zip directory or zip --exclude *.git* -r directory.zip directory

            – Dmitry Minkovsky
            May 29 '14 at 19:37






          • 6





            If you're worried about losing other files called something.gitwhatever, you can also use --exclude /.git*.

            – Erin Call
            Sep 25 '14 at 21:54






          • 4





            in ZSH I had to add a backslash: -x *.git*

            – DmitrySandalov
            Dec 6 '14 at 20:14






          • 2





            My preferred alternative to backslashes and quotes in zsh: noglob zip -r out.zip someFolder -x *someExcludedFolder*

            – Sébastien
            Oct 19 '15 at 14:09













          • How to use it with tar? Its not working with tar command.

            – RN Kushwaha
            Sep 20 '16 at 7:03



















          103














          If you're trying to zip up a project which is stored in Git, use the git archive command. From within the source directory:



          git archive -o bitvolution.zip HEAD


          You can use any commit or tag ID instead of HEAD to archive the project at a certain point.



          If you want to add a prefix (e.g., a top level folder) to every file:



          git archive -o bitvolution.zip --prefix=bitvolution/ HEAD


          You can also adjust the compression level between 0 (no compression) and 9 (maximum compression) inclusive, for example



          git archive -o bitvolution.zip -9 HEAD


          For other options, see the help page (git help archive).






          share|improve this answer



















          • 20





            Not only will this not include the git folder but also anything that is in the gitignore file will be excluded as well. You sir get an upvote.

            – JoeMoe1984
            Oct 21 '14 at 10:04






          • 1





            Just what I was looking to do!

            – Bjarte
            Oct 21 '17 at 11:41











          • I'm late to the party but this absolutely blew me away. Great answer!

            – Tom
            Oct 25 '17 at 10:14











          • i wonder why isn't this the best answer

            – nabtron
            Jun 7 '18 at 1:52











          • for me this was the greatest TIL today...

            – Shawn Cicoria - MSFT
            Jul 8 '18 at 17:12



















          22














          I added backslash:



          zip -r bitvolution.zip bitvolution -x *.git*


          man page about backslash:




          The backslash avoids the shell filename substitution, so that the name
          matching is performed by zip at all directory levels.







          share|improve this answer
























          • prepending asterisks with slash forks for me on Ubuntu 14.04 to exclude directories

            – Dimitry K
            Mar 23 '16 at 17:04



















          5














          Assuming you have git installed on the machine you are doing this, you can also use git itself to create your archive.



          git archive --format=zip HEAD -o bitvolution.zip





          share|improve this answer































            1














            If you are using zsh, command should look like:



            zip -r target_name.zip source_dir -x '/*.git/*'


            If you use: zip -r target_name.zip source_dir -x /*.git/*.
            without 'regex', zsh will process before zip run. You will get error message:



            zsh: no matches found: /*.git/*





            share|improve this answer


























            • Thanks! That's what worked for me using Bash on Ubuntu on Windows.

              – Adriano Monecchi
              Aug 30 '18 at 11:48











            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "89"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f28476%2fhow-do-i-zip-up-a-folder-but-exclude-the-git-subfolder%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            5 Answers
            5






            active

            oldest

            votes








            5 Answers
            5






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            203














            The correct expression is -x *.git*, so the full command should be:



            zip -r bitvolution.zip bitvolution -x *.git*


            An explanation from http://selfsolved.com/problems/zip-command-exclude-svn-director:




            The correct incantation is



            zip -9 -r --exclude=*.svn*  foo.zip [directory-to-compress]


            You can also add a
            --exclude=*.DS_Store* to exclude the annoying Mac OS X directory display metadata files.



            Notice that the expression passed to --exclude is using the entire original relative directory path as the original string to match against. So .svn/* by itself doesn't work; the wildcard character in front ensures that it matches .svn directories anywhere in the directory tree.







            share|improve this answer



















            • 12





              I had to wrap the glob in quotes or escape the asterisks with backslashes, like zip --exclude '*.git*' -r directory.zip directory or zip --exclude *.git* -r directory.zip directory

              – Dmitry Minkovsky
              May 29 '14 at 19:37






            • 6





              If you're worried about losing other files called something.gitwhatever, you can also use --exclude /.git*.

              – Erin Call
              Sep 25 '14 at 21:54






            • 4





              in ZSH I had to add a backslash: -x *.git*

              – DmitrySandalov
              Dec 6 '14 at 20:14






            • 2





              My preferred alternative to backslashes and quotes in zsh: noglob zip -r out.zip someFolder -x *someExcludedFolder*

              – Sébastien
              Oct 19 '15 at 14:09













            • How to use it with tar? Its not working with tar command.

              – RN Kushwaha
              Sep 20 '16 at 7:03
















            203














            The correct expression is -x *.git*, so the full command should be:



            zip -r bitvolution.zip bitvolution -x *.git*


            An explanation from http://selfsolved.com/problems/zip-command-exclude-svn-director:




            The correct incantation is



            zip -9 -r --exclude=*.svn*  foo.zip [directory-to-compress]


            You can also add a
            --exclude=*.DS_Store* to exclude the annoying Mac OS X directory display metadata files.



            Notice that the expression passed to --exclude is using the entire original relative directory path as the original string to match against. So .svn/* by itself doesn't work; the wildcard character in front ensures that it matches .svn directories anywhere in the directory tree.







            share|improve this answer



















            • 12





              I had to wrap the glob in quotes or escape the asterisks with backslashes, like zip --exclude '*.git*' -r directory.zip directory or zip --exclude *.git* -r directory.zip directory

              – Dmitry Minkovsky
              May 29 '14 at 19:37






            • 6





              If you're worried about losing other files called something.gitwhatever, you can also use --exclude /.git*.

              – Erin Call
              Sep 25 '14 at 21:54






            • 4





              in ZSH I had to add a backslash: -x *.git*

              – DmitrySandalov
              Dec 6 '14 at 20:14






            • 2





              My preferred alternative to backslashes and quotes in zsh: noglob zip -r out.zip someFolder -x *someExcludedFolder*

              – Sébastien
              Oct 19 '15 at 14:09













            • How to use it with tar? Its not working with tar command.

              – RN Kushwaha
              Sep 20 '16 at 7:03














            203












            203








            203







            The correct expression is -x *.git*, so the full command should be:



            zip -r bitvolution.zip bitvolution -x *.git*


            An explanation from http://selfsolved.com/problems/zip-command-exclude-svn-director:




            The correct incantation is



            zip -9 -r --exclude=*.svn*  foo.zip [directory-to-compress]


            You can also add a
            --exclude=*.DS_Store* to exclude the annoying Mac OS X directory display metadata files.



            Notice that the expression passed to --exclude is using the entire original relative directory path as the original string to match against. So .svn/* by itself doesn't work; the wildcard character in front ensures that it matches .svn directories anywhere in the directory tree.







            share|improve this answer













            The correct expression is -x *.git*, so the full command should be:



            zip -r bitvolution.zip bitvolution -x *.git*


            An explanation from http://selfsolved.com/problems/zip-command-exclude-svn-director:




            The correct incantation is



            zip -9 -r --exclude=*.svn*  foo.zip [directory-to-compress]


            You can also add a
            --exclude=*.DS_Store* to exclude the annoying Mac OS X directory display metadata files.



            Notice that the expression passed to --exclude is using the entire original relative directory path as the original string to match against. So .svn/* by itself doesn't work; the wildcard character in front ensures that it matches .svn directories anywhere in the directory tree.








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Feb 28 '11 at 21:01









            IsaiahIsaiah

            43.4k21118138




            43.4k21118138








            • 12





              I had to wrap the glob in quotes or escape the asterisks with backslashes, like zip --exclude '*.git*' -r directory.zip directory or zip --exclude *.git* -r directory.zip directory

              – Dmitry Minkovsky
              May 29 '14 at 19:37






            • 6





              If you're worried about losing other files called something.gitwhatever, you can also use --exclude /.git*.

              – Erin Call
              Sep 25 '14 at 21:54






            • 4





              in ZSH I had to add a backslash: -x *.git*

              – DmitrySandalov
              Dec 6 '14 at 20:14






            • 2





              My preferred alternative to backslashes and quotes in zsh: noglob zip -r out.zip someFolder -x *someExcludedFolder*

              – Sébastien
              Oct 19 '15 at 14:09













            • How to use it with tar? Its not working with tar command.

              – RN Kushwaha
              Sep 20 '16 at 7:03














            • 12





              I had to wrap the glob in quotes or escape the asterisks with backslashes, like zip --exclude '*.git*' -r directory.zip directory or zip --exclude *.git* -r directory.zip directory

              – Dmitry Minkovsky
              May 29 '14 at 19:37






            • 6





              If you're worried about losing other files called something.gitwhatever, you can also use --exclude /.git*.

              – Erin Call
              Sep 25 '14 at 21:54






            • 4





              in ZSH I had to add a backslash: -x *.git*

              – DmitrySandalov
              Dec 6 '14 at 20:14






            • 2





              My preferred alternative to backslashes and quotes in zsh: noglob zip -r out.zip someFolder -x *someExcludedFolder*

              – Sébastien
              Oct 19 '15 at 14:09













            • How to use it with tar? Its not working with tar command.

              – RN Kushwaha
              Sep 20 '16 at 7:03








            12




            12





            I had to wrap the glob in quotes or escape the asterisks with backslashes, like zip --exclude '*.git*' -r directory.zip directory or zip --exclude *.git* -r directory.zip directory

            – Dmitry Minkovsky
            May 29 '14 at 19:37





            I had to wrap the glob in quotes or escape the asterisks with backslashes, like zip --exclude '*.git*' -r directory.zip directory or zip --exclude *.git* -r directory.zip directory

            – Dmitry Minkovsky
            May 29 '14 at 19:37




            6




            6





            If you're worried about losing other files called something.gitwhatever, you can also use --exclude /.git*.

            – Erin Call
            Sep 25 '14 at 21:54





            If you're worried about losing other files called something.gitwhatever, you can also use --exclude /.git*.

            – Erin Call
            Sep 25 '14 at 21:54




            4




            4





            in ZSH I had to add a backslash: -x *.git*

            – DmitrySandalov
            Dec 6 '14 at 20:14





            in ZSH I had to add a backslash: -x *.git*

            – DmitrySandalov
            Dec 6 '14 at 20:14




            2




            2





            My preferred alternative to backslashes and quotes in zsh: noglob zip -r out.zip someFolder -x *someExcludedFolder*

            – Sébastien
            Oct 19 '15 at 14:09







            My preferred alternative to backslashes and quotes in zsh: noglob zip -r out.zip someFolder -x *someExcludedFolder*

            – Sébastien
            Oct 19 '15 at 14:09















            How to use it with tar? Its not working with tar command.

            – RN Kushwaha
            Sep 20 '16 at 7:03





            How to use it with tar? Its not working with tar command.

            – RN Kushwaha
            Sep 20 '16 at 7:03













            103














            If you're trying to zip up a project which is stored in Git, use the git archive command. From within the source directory:



            git archive -o bitvolution.zip HEAD


            You can use any commit or tag ID instead of HEAD to archive the project at a certain point.



            If you want to add a prefix (e.g., a top level folder) to every file:



            git archive -o bitvolution.zip --prefix=bitvolution/ HEAD


            You can also adjust the compression level between 0 (no compression) and 9 (maximum compression) inclusive, for example



            git archive -o bitvolution.zip -9 HEAD


            For other options, see the help page (git help archive).






            share|improve this answer



















            • 20





              Not only will this not include the git folder but also anything that is in the gitignore file will be excluded as well. You sir get an upvote.

              – JoeMoe1984
              Oct 21 '14 at 10:04






            • 1





              Just what I was looking to do!

              – Bjarte
              Oct 21 '17 at 11:41











            • I'm late to the party but this absolutely blew me away. Great answer!

              – Tom
              Oct 25 '17 at 10:14











            • i wonder why isn't this the best answer

              – nabtron
              Jun 7 '18 at 1:52











            • for me this was the greatest TIL today...

              – Shawn Cicoria - MSFT
              Jul 8 '18 at 17:12
















            103














            If you're trying to zip up a project which is stored in Git, use the git archive command. From within the source directory:



            git archive -o bitvolution.zip HEAD


            You can use any commit or tag ID instead of HEAD to archive the project at a certain point.



            If you want to add a prefix (e.g., a top level folder) to every file:



            git archive -o bitvolution.zip --prefix=bitvolution/ HEAD


            You can also adjust the compression level between 0 (no compression) and 9 (maximum compression) inclusive, for example



            git archive -o bitvolution.zip -9 HEAD


            For other options, see the help page (git help archive).






            share|improve this answer



















            • 20





              Not only will this not include the git folder but also anything that is in the gitignore file will be excluded as well. You sir get an upvote.

              – JoeMoe1984
              Oct 21 '14 at 10:04






            • 1





              Just what I was looking to do!

              – Bjarte
              Oct 21 '17 at 11:41











            • I'm late to the party but this absolutely blew me away. Great answer!

              – Tom
              Oct 25 '17 at 10:14











            • i wonder why isn't this the best answer

              – nabtron
              Jun 7 '18 at 1:52











            • for me this was the greatest TIL today...

              – Shawn Cicoria - MSFT
              Jul 8 '18 at 17:12














            103












            103








            103







            If you're trying to zip up a project which is stored in Git, use the git archive command. From within the source directory:



            git archive -o bitvolution.zip HEAD


            You can use any commit or tag ID instead of HEAD to archive the project at a certain point.



            If you want to add a prefix (e.g., a top level folder) to every file:



            git archive -o bitvolution.zip --prefix=bitvolution/ HEAD


            You can also adjust the compression level between 0 (no compression) and 9 (maximum compression) inclusive, for example



            git archive -o bitvolution.zip -9 HEAD


            For other options, see the help page (git help archive).






            share|improve this answer













            If you're trying to zip up a project which is stored in Git, use the git archive command. From within the source directory:



            git archive -o bitvolution.zip HEAD


            You can use any commit or tag ID instead of HEAD to archive the project at a certain point.



            If you want to add a prefix (e.g., a top level folder) to every file:



            git archive -o bitvolution.zip --prefix=bitvolution/ HEAD


            You can also adjust the compression level between 0 (no compression) and 9 (maximum compression) inclusive, for example



            git archive -o bitvolution.zip -9 HEAD


            For other options, see the help page (git help archive).







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 14 '11 at 11:08









            BlairBlair

            1,73611316




            1,73611316








            • 20





              Not only will this not include the git folder but also anything that is in the gitignore file will be excluded as well. You sir get an upvote.

              – JoeMoe1984
              Oct 21 '14 at 10:04






            • 1





              Just what I was looking to do!

              – Bjarte
              Oct 21 '17 at 11:41











            • I'm late to the party but this absolutely blew me away. Great answer!

              – Tom
              Oct 25 '17 at 10:14











            • i wonder why isn't this the best answer

              – nabtron
              Jun 7 '18 at 1:52











            • for me this was the greatest TIL today...

              – Shawn Cicoria - MSFT
              Jul 8 '18 at 17:12














            • 20





              Not only will this not include the git folder but also anything that is in the gitignore file will be excluded as well. You sir get an upvote.

              – JoeMoe1984
              Oct 21 '14 at 10:04






            • 1





              Just what I was looking to do!

              – Bjarte
              Oct 21 '17 at 11:41











            • I'm late to the party but this absolutely blew me away. Great answer!

              – Tom
              Oct 25 '17 at 10:14











            • i wonder why isn't this the best answer

              – nabtron
              Jun 7 '18 at 1:52











            • for me this was the greatest TIL today...

              – Shawn Cicoria - MSFT
              Jul 8 '18 at 17:12








            20




            20





            Not only will this not include the git folder but also anything that is in the gitignore file will be excluded as well. You sir get an upvote.

            – JoeMoe1984
            Oct 21 '14 at 10:04





            Not only will this not include the git folder but also anything that is in the gitignore file will be excluded as well. You sir get an upvote.

            – JoeMoe1984
            Oct 21 '14 at 10:04




            1




            1





            Just what I was looking to do!

            – Bjarte
            Oct 21 '17 at 11:41





            Just what I was looking to do!

            – Bjarte
            Oct 21 '17 at 11:41













            I'm late to the party but this absolutely blew me away. Great answer!

            – Tom
            Oct 25 '17 at 10:14





            I'm late to the party but this absolutely blew me away. Great answer!

            – Tom
            Oct 25 '17 at 10:14













            i wonder why isn't this the best answer

            – nabtron
            Jun 7 '18 at 1:52





            i wonder why isn't this the best answer

            – nabtron
            Jun 7 '18 at 1:52













            for me this was the greatest TIL today...

            – Shawn Cicoria - MSFT
            Jul 8 '18 at 17:12





            for me this was the greatest TIL today...

            – Shawn Cicoria - MSFT
            Jul 8 '18 at 17:12











            22














            I added backslash:



            zip -r bitvolution.zip bitvolution -x *.git*


            man page about backslash:




            The backslash avoids the shell filename substitution, so that the name
            matching is performed by zip at all directory levels.







            share|improve this answer
























            • prepending asterisks with slash forks for me on Ubuntu 14.04 to exclude directories

              – Dimitry K
              Mar 23 '16 at 17:04
















            22














            I added backslash:



            zip -r bitvolution.zip bitvolution -x *.git*


            man page about backslash:




            The backslash avoids the shell filename substitution, so that the name
            matching is performed by zip at all directory levels.







            share|improve this answer
























            • prepending asterisks with slash forks for me on Ubuntu 14.04 to exclude directories

              – Dimitry K
              Mar 23 '16 at 17:04














            22












            22








            22







            I added backslash:



            zip -r bitvolution.zip bitvolution -x *.git*


            man page about backslash:




            The backslash avoids the shell filename substitution, so that the name
            matching is performed by zip at all directory levels.







            share|improve this answer













            I added backslash:



            zip -r bitvolution.zip bitvolution -x *.git*


            man page about backslash:




            The backslash avoids the shell filename substitution, so that the name
            matching is performed by zip at all directory levels.








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 14 '11 at 10:13









            Priit TamboomPriit Tamboom

            22122




            22122













            • prepending asterisks with slash forks for me on Ubuntu 14.04 to exclude directories

              – Dimitry K
              Mar 23 '16 at 17:04



















            • prepending asterisks with slash forks for me on Ubuntu 14.04 to exclude directories

              – Dimitry K
              Mar 23 '16 at 17:04

















            prepending asterisks with slash forks for me on Ubuntu 14.04 to exclude directories

            – Dimitry K
            Mar 23 '16 at 17:04





            prepending asterisks with slash forks for me on Ubuntu 14.04 to exclude directories

            – Dimitry K
            Mar 23 '16 at 17:04











            5














            Assuming you have git installed on the machine you are doing this, you can also use git itself to create your archive.



            git archive --format=zip HEAD -o bitvolution.zip





            share|improve this answer




























              5














              Assuming you have git installed on the machine you are doing this, you can also use git itself to create your archive.



              git archive --format=zip HEAD -o bitvolution.zip





              share|improve this answer


























                5












                5








                5







                Assuming you have git installed on the machine you are doing this, you can also use git itself to create your archive.



                git archive --format=zip HEAD -o bitvolution.zip





                share|improve this answer













                Assuming you have git installed on the machine you are doing this, you can also use git itself to create your archive.



                git archive --format=zip HEAD -o bitvolution.zip






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 14 '11 at 11:12









                Tatu LahtelaTatu Lahtela

                26422




                26422























                    1














                    If you are using zsh, command should look like:



                    zip -r target_name.zip source_dir -x '/*.git/*'


                    If you use: zip -r target_name.zip source_dir -x /*.git/*.
                    without 'regex', zsh will process before zip run. You will get error message:



                    zsh: no matches found: /*.git/*





                    share|improve this answer


























                    • Thanks! That's what worked for me using Bash on Ubuntu on Windows.

                      – Adriano Monecchi
                      Aug 30 '18 at 11:48
















                    1














                    If you are using zsh, command should look like:



                    zip -r target_name.zip source_dir -x '/*.git/*'


                    If you use: zip -r target_name.zip source_dir -x /*.git/*.
                    without 'regex', zsh will process before zip run. You will get error message:



                    zsh: no matches found: /*.git/*





                    share|improve this answer


























                    • Thanks! That's what worked for me using Bash on Ubuntu on Windows.

                      – Adriano Monecchi
                      Aug 30 '18 at 11:48














                    1












                    1








                    1







                    If you are using zsh, command should look like:



                    zip -r target_name.zip source_dir -x '/*.git/*'


                    If you use: zip -r target_name.zip source_dir -x /*.git/*.
                    without 'regex', zsh will process before zip run. You will get error message:



                    zsh: no matches found: /*.git/*





                    share|improve this answer















                    If you are using zsh, command should look like:



                    zip -r target_name.zip source_dir -x '/*.git/*'


                    If you use: zip -r target_name.zip source_dir -x /*.git/*.
                    without 'regex', zsh will process before zip run. You will get error message:



                    zsh: no matches found: /*.git/*






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Jun 8 '18 at 9:58









                    Thomas

                    3,76981527




                    3,76981527










                    answered Jun 8 '18 at 9:35









                    g10guangg10guang

                    1112




                    1112













                    • Thanks! That's what worked for me using Bash on Ubuntu on Windows.

                      – Adriano Monecchi
                      Aug 30 '18 at 11:48



















                    • Thanks! That's what worked for me using Bash on Ubuntu on Windows.

                      – Adriano Monecchi
                      Aug 30 '18 at 11:48

















                    Thanks! That's what worked for me using Bash on Ubuntu on Windows.

                    – Adriano Monecchi
                    Aug 30 '18 at 11:48





                    Thanks! That's what worked for me using Bash on Ubuntu on Windows.

                    – Adriano Monecchi
                    Aug 30 '18 at 11:48


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f28476%2fhow-do-i-zip-up-a-folder-but-exclude-the-git-subfolder%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                    Mangá

                    Eduardo VII do Reino Unido