6

I deleted a file ages ago. I don't remember the commit ID or the branch, just the folder the file was contained within.

What's the easiest way to find this file in Gitlab/see what code was in the file?

I can't see any obvious way in the GUI how to achieve this. Google'd but the results referred to finding them in Git, not Gitlab.

user997112
  • 29,025
  • 43
  • 182
  • 361
  • Why do you not want to use the [command line](https://stackoverflow.com/questions/953481/find-and-restore-a-deleted-file-in-a-git-repository)? – flaxel Oct 01 '20 at 19:10
  • @flaxel Because I want to see the history of the file in Gitlab – user997112 Oct 05 '20 at 11:53
  • You can use the history also with the `git log ` command. – flaxel Oct 05 '20 at 12:06
  • 3
    @flaxel I want to see the history graphically, as per Gitlab. Same as what Gitlab normally shows, just for a file which was deleted in the past. – user997112 Oct 05 '20 at 20:26

1 Answers1

10

Came across this in Google and I had the same issue, couldn't find a solution in the current version of the GitLab GUI.

As a workaround from not finding a way to do it in the GUI directly, I ended up cloning the project and using the Git CLI:

git log --all --full-history -- **/myfile.ext

The top commit on this was the commit that deleted the file. You can then browse the commit itself on the GitLab GUI using the commit ID.

Hopefully they'll add better support for this in a future version (unless I just can't find it), but at least this is a workaround.

Christian Wilkie
  • 3,693
  • 5
  • 34
  • 49
  • 1
    Thanks for answering. Can't accept as full answer but i've given an upvote for the help. – user997112 Jun 22 '21 at 12:25
  • @user997112 yeah totally understandable, just wanted to give a workaround in case others have the same issue and found this page when googling it like I did. Would be great if there is an easy way to do this in the GUI – Christian Wilkie Jun 22 '21 at 14:38