I'm working on a project in git, and I know that at some time in the past (long before I had the code) there existed a file called exec.js
.
I want to view the contents of this file.
I know which repository used to contain this file, but I don't know the exact path.
You could use wildcard characters in git log
:
git log -- *exec.js
will give you all log messages when any file called exec.js
was modified.
Once you find the deleting commit (say A
), you could
git checkout A -- *exec.js
This will bring you the last version of exec.js
.
If you want to view the full history of exec.js
, you could use gitk
:
gitk -- *exec.js
This will show you all the modifications again. If you're particularly interested in one commit, you could right click the file in the gitk
dialog and then select external diff tool. This will open the external diff tool with the full files, not only the patches.
You can search for that particular file inside log history using -
If you don't have filepath then
git log --diff-filter=D --summary | grep filename
If you have filepath then you can use -
git log -- filepath
git log -n 1 -- filepath
and once you get the revision you can checkout that particular revision to get that file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With