Search code examples
mercurialtortoisehgbitbucket

Bitbucket/Mercurial/Tortoise How do I add a folder to a Bitbucket repo?


I'm working on a project with 2 other people and want to create separate folders for each of us in a Bitbucket repo. I've tried creating the folders on my machine and pushing it up to the repo but this isn't working.

Any suggestions?


Solution

  • To create a folder, you need to create a file in that folder and add it to the repository, then you can push it. Mercurial tracks changes to files, so if a folder has no "content" then it will not be tracked.

    Say you had a base source file that you wanted in each directory (we'll call it main.cpp), you could create the folders like so:

    $ mkdir folder1
    $ mkdir folder2
    $ hg st
    

    Note that nothing is listed in response to the status, as there are no new files.

    $ cp main.cpp folder1
    $ cp main.cpp folder2
    $ hg st
    ? folder1/main.cpp
    ? folder2/main.cpp
    

    The above shows that adding files to the folders makes them "visible" to Mercurial.

    $ hg add
    $ hg st
    + folder1/main.cpp
    + folder2/main.cpp
    

    Now the files are marked as added, and so when you commit they'll exist in the repository.

    Note that the above was an example to demonstrate that you need files in a folder for it to be seen.