Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,670
Community Members
 
Community Events
176
Community Groups

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.

LogSelectedIsDIm.png

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
TAGS

Atlassian Community Events