Search code examples
version-controlmercurialdvcsbitbuckethgignore

Prevent a directory from being pushed in mercurial


I created a new repository on my local computer, added files and committed giving me the following structure in my working copy:

-/a     
-/b

I want to push my initial commit to a remote repository on Bitbucket. I however want to ignore directory b so that it doesn't get pushed. I added

syntax:
glob b/**

to my .hgignore file. The b directory gets pushed anyways.

How can I prevent this?


Solution

  • in .hgignore add:

    ^b/.*
    

    or b/* if you are using the inferior glob syntax (regex gives you much more control).

    The syntax is defined on the first line, and all rules are defined in following seperate lines.

    if you want globbing, the first line would be syntax: glob and if regex, the first line would be syntax: regexp (implied by default). Refer to the documentation.

    Note that mercurial does not actually push empty directories, so the only way you will be able to test it is if you have a file in b/