Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Staging in shared submodule deletes file


I set up a shared submodule, and whenever I stage a file in Sourcetree it shows that all files contents are deleted, so effectively Sourcetree states that I am staging a deleted file. When I unstage, the file is deleted. When I add the file via the terminal, it all works flawlessly. I think the tricky thing here is the shared submodule part, with which Sourcetree has trouble. While it could be that I am doing something wrong, I have the belief that Sourcetree is doing more than a simple 'git add' (as that works from the command line).

I set up the shared submodule as followed:

1. Clone the project that should serve as the shared submodule locally to some directory
2. In the shared submodule, modify the local config of this project by adding 'worktree = ..' under [core]

For all projects sharing this submodule:

3. Add the submodule (this means, effectively I now have two checked out copies of that project)
4. Delete the respective submodule folder in ./git/submodule/
5. Delete the content of the submodule directory apart from the .git file
6. Modify the .git in the submodule directory to point to the path of the project setup in 1)


1 answer

0 votes
minnsey Atlassian Team Apr 08, 2019


I think you summary is probably correct, we certainly don't test such a shared submodule setup.

Can I ask why you do it like this rather than having the submodule available via a remote and each parent project simply adding it as a standard submodule from that remote? 

Sure, that is because I do not want to have several different copies checked out. This facilitates working across projects. If I'd use the standard way, if I change a file in a submodule in one project, the file would not be changed in the respective submodule in all other projects. I would have to commit it first, and then pull in all my other projects. With a shared submodule, I change a file in one project, and the changes are 'automatically' applied to all projects sharing this same submodule.


I see that I posted this under questions, but I forgot to ask one. So here it is: Given my setup above and the problem I run into, is this a bug in Sourcetree?

minnsey Atlassian Team Apr 09, 2019

Possibly ;) Could you raise a ticket at Thanks

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

7,187 views 5 13
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you