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 to recover deleted & committed files from the remote repository?

A coworker deleted some files and committed them. Without paying too much attention, I pulled his changes and committed them. 16 of the files he deleted should not have been and now neither of us has a copy of them.

I figured this was no problem, I will simply reset each of the files to their last commit. As I understand it, the procedure is to go to the commit where the files were deleted, then right-click on each file and select menu item "Log Selected..." which will point me at the desired commit. But when I select one of the files and right-click on it, the "Log Selected..." menu item is dim! It seems to be dim for all of the deleted files, but is OK for the files that were just changed.

What am I missing? I would hate to have to look through a ton of commits to find each of the 16 files!!! Help! The Sourcetree version is 3.3.8.


1 answer

1 accepted

0 votes
Answer accepted
prashant_gami Community Leader Jul 27, 2020

If the commit only has file deletion, you can reverse commit it, it's easier.

Go to commit, Right click, and then reverse commit.

Or you can "Reset to commit" to a previous commit and then cherry pick commits that you want there.


PS: you will have to force push if you choose reset to commit as you are overriding the history. So make sure you cherry pick all the stuff that you actually want or else will be overwritten by push.


The menu you are showing seems bit off with few options disabled. Can you give more details?

Hi Prashant, sorry for not responding sooner, but we did manage to find a recent version of the files so were able to restore them that way.

I was reluctant to try the Reset to commit option because I didn't know Git well enough to understand all the ramifications.

I didn't think of doing the "Reverse commit" on the entire commit. There were a bunch other files changed, but it would have been relatively easy to discard those changes before committing the reversal.

As it was, I was trying to just reverse the commit for each of the erroneously deleted files, as was suggested by a post from 2015 on this forum), but was stymied by the "log selected" menu item being dim for the individual deleted files (it was available for the changed files in that commit). I agree that it looks "off" and seems like a bug because reversing the removal of a file is easily reversible!

To recap what that post said to do:

1. Go to the commit that deleted the files.
2. Right-click on the deleted file and select "Log Selected" menu item.
3. Determine when the file was last committed.
4. Go to that commit
5. Right-click on the deleted file and select "Reset to commit" menu item.

Seems like it's a Sourcetree bug that "log selected" is dim in step 2.

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,218 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