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

How do I change the main working tree location without losing my files?

I'm looking to have the repository track files that are not in the same folder or subfolder as the `.git` folder by making the Main Working Tree a different folder. This is completely allowed in git and required for a use case of mine (the folder to be tracked is occasionally deleted and regenerated entirely by the IDE, which would delete the `.git` folder as well).

This is a loaded question; I'm miffed about a 3 year old Sourcetree for Windows bug (duplicate) that deletes files instead of staging them and it was just suggested to me it is not a bug, I'm just not doing it right. So what is the SourceTree approved way to change the location of the main working tree?

The way I have been doing it is to edit the repository config files to add:  
`worktree = C:\\Some\\Path` and git starts tracking that folder instead of the one containing the `.git` folder. This works fine when only using git via the terminal or alternate GUIs, but attempting to stage a file in SourceTree will delete it instead. Yes, staging a file you just worked on will delete it. Not just fail to stage it, it is gone. It isn't in the recycle bin, SourceTree deleted it just when you were hoping to save your changes to git.

So, if editing the repo config file isn't how you change the main working tree location in SourceTree, then how do you do it?

0 answers

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,241 views 5 14
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