How do I restore a missing local repository from remote?

When I delete the main folder of my local repository (because I'm currently not working on it, and its on the same version as the remote) the SourceTree Repository Browser gives me the error message "Repository moved or deleted".

That's fine. But then my only options are to delete the Bookmark or specify another location with a version of the repository. But what if I don't have a local version and just want to continue to work on the most current, remote version?

I don't even see a possibility to get the original remote URL. So I'd have to delete the Bookmark in the SourceTree Browser, somehow retrieve the original remote URL and recreate it again as new repository... is that the only way?

1 answer

I cannot imagine another way ATM.

When you delete a local repository - you usually also remove the .git-folder. Within the .git-folder within the .config-file the remote URL is stored. By removing the local repository you therefore also remove the information about the original remote URL. As SourceTree does not store the remote URL internally but rather relies on the presence of the .git/.config file as source for the remote URL, deleting this file makes SourceTree acgnostic of the former remote URL.

The only way I see, is to clone your repository again and add it to SourceTree again ...

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
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 ...

791 views 0 4
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