You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.