Cannot add existing subtree to SourceTree

Following these instructions, I created subtree through the terminal. I added a remote for it (hosted at GitHub) and everything has been working as expected on the terminal. However, in Subtree when I try to "add/link" the subtree it keeps complaining that it already exists.

Is there any way to get SourceTree to recognize the subtree without removing it and recreating it through SourceTree?

7 answers

1 accepted

Kieran Senior's comment fixed the problem for me:

Yeah, this is because it's supposed to be a relative path. The dialog label says "Local relative path" but we don't detect for this at the moment. Unfortunately Git's errors aren't of much help. The Git command lets you carry on regardless.

If it's an existing path (the paths must always be within your main repository directory), then you create a link. Adding a subtree to an existing path yields in a Git error. If it's a brand new subtree then it needs to be a non-existent directory in your repository directory.

We've got a couple of open issues to improve this so when you select a folder using the directory picker (the triple dot button) then it'll yield a relative path, or if it's outside your repo folder then it'll yield an error. I've been meaning to do this but only a couple of people spotted it. That adds two more to my list now.

In your case it looks like the path should be web/sites/all/modules/asset_saver

Cheers

It should be noted that the [...] button next to the "Local Relative Path:" field generates an absolute path instead of the required relative path.

3 August 2017

THIS BUG IS NOW THREE YEARS OLD AND STILL PRESENT.

How about fixing it...

It is intuitive to trust the directory picker.  It has taken me hours to solve why every subtree I add crashes.

I also have this problem

This is not an answer, this is a comment. Please delete this and move it to a comment on the main question.

If it's asking to create a link, you simply say "Create Link". All this does is create a link between the specified repository and that sub-folder of your repository within SourceTree. It's metadata stored by SourceTree, nothing more. This is used so you can perform subtree actions without having to specify the remote each time.

Subtree is very disconnected in that no metadata is stored for each subtree, so we store it for you so you can perform actions quickly. If you were to do this at the terminal you'd have to specify the remote each time, with SourceTree you don't.

I'm assuming we're talking about the above dialog. The message tells you what's happening and that it won't affect anything.

This is not the problem. I don't even get to that dialog. Screenshot of the error message.

This is not what's happenning. It doesn't get to this dialog showing error before.

Yeah, this is because it's supposed to be a relative path. The dialog label says "Local relative path" but we don't detect for this at the moment. Unfortunately Git's errors aren't of much help. The Git command lets you carry on regardless.

If it's an existing path (the paths must always be within your main repository directory), then you create a link. Adding a subtree to an existing path yields in a Git error. If it's a brand new subtree then it needs to be a non-existent directory in your repository directory.

We've got a couple of open issues to improve this so when you select a folder using the directory picker (the triple dot button) then it'll yield a relative path, or if it's outside your repo folder then it'll yield an error. I've been meaning to do this but only a couple of people spotted it. That adds two more to my list now.

In your case it looks like the path should be web/sites/all/modules/asset_saver

Cheers

That fixed the problem. The reason I didn't think about entering a relative path is because I just used the [...] (browse) button and it generated an absolute path. I assumed that whatever it generated would be valid.

It does not work here.

My dir is as follows:

ProjectDir/subtrees/AFNetworking

When trying to link the subtree to Sourcetree, I use:

subtrees/AFNetworking

as relative path but I get the "already exists" error shown in the original question.

Same here. Changing manually to the realtive path didn't solve the problem.

You guys may want to start a new question since it seems like this solution isn't working for you. It may be that the Atlassian members already see this question as solved and so are ignoring further comments on it.

This is not what's happenning. It doesn't get to this dialog showing error before.

This is not an answer, this is a comment. Please delete this and add it as a comment on the answer you're responding to.

I spend more than an hour trying to add a subtree because of the "source path/url" and "Local relative path". I use source tree 1.8.3.0

Thanks to God, it worked very well in the end. But I had to create the subtree as follow :

1 "Local relative path": It has to be relative to the main project

2 "Local relative path": it has to have linux slashes ( / ) ad not backslashes ( \ ), else the git command don' t work.

3 "Source path / url" has to be a local path on my computer, it didn't worked with a private repository on bitbucket...

Well, that part of sourcetree need some debugging, but at least now it works very well.

 

Thank you for the fantastic Source Tree !

There were a couple of fixes issued, so this shouldn't be happening any more. What version are you on?

+1

same issue

Repro szenario:

Suggest an answer

Log in or Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

236 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot