Search code examples
gitbitbucketatlassian-sourcetreebitbucket-server

How to get files into my local in SourceTree?


I have a local repository which I cloned from the remote server. A large number of files were deleted from my hard drive and I want to get them back from the remore repository (which is on a BitBucket server).

I'm the only user in the repo. The only branch where I am doing any work is master.

Neither "Pull" nor "Fetch" are bringing my files down from the repote repo. Completely removing the repository from my computer and then cloning it seems like overkill.

How do I get SourceTree to simply grab all of the files from the remote repository and put them on my computer?


Solution

  • Try switching to command line from SourceTree, and a git checkout with a path:

    git checkout master -- .
    

    Or, since Git 2.23 and the git restore command, as seen here:

    git restore --source=HEAD --staged --worktree -- .
    

    Or, with git switch (again, Git 2.23)

    git switch -C master origin/master