James Raitsev
James Raitsev

Reputation: 96521

How to search git branch for a file name once committed?

A while back in a known branch i committed a file, which was subsequently removed. Many iterations later, i'd like to recover this file.

How can this be done please?

Upvotes: 1

Views: 83

Answers (2)

twalberg
twalberg

Reputation: 62499

If you remember the file name, you can just run git log -- <filename> to show all commits that involved that file. If you don't remember the file name, but remember something about the contents, you can use git log -S <string> or git log -G <regex> to search for it.

Upvotes: 3

hnasarat
hnasarat

Reputation: 191

git log -U | less

find the most recent commit that referenced the filename

git checkout MOST-RECENT-COMMIT FILENAME

Upvotes: 0

Related Questions