Search code examples
gitbitbucketgit-subtree

Add 2 local locations to same Git repo


I've been googling on Git for a few hours now and I'm going nowhere, so hope you can help.

I have a local path /path/to/somewhere/ And this is in sync with my remote BitBucket repo https://bitbucket.org/company/somewhere.git

Now I want to add another folder like /path/to/there/ And I want it to appear in the same repository https://bitbucket.org/company/somewhere.git/there/

I tried using "git subtree add --prefix=there https://bitbucket.org/company/somewhere.git" but it responds with:

prefix 'somewhere' already exists.

When I log in to Bitbucket and check, it doesnt.


Solution

  • Git doesn't work like this you have to have one more repository for /path/to/there/ to be able to include it into your /path/to/somewhere/ as a sub directory. When you have two repository you can:

    $ cd /path/to/somewhere/
    $ git subtree add --prefix=there https://bitbucket.org/company/THERE.git master
    

    Then a new directory there appeares in the /path/to/somewhere/.

    For more information take a look at this