0

How to find when a specific file existed in git history and how long, and how to get all its versions?

I tried

git log --all -- **/thefile.*

and it doesn't output anything.

The command

git --no-pager log --all --full-history --summary > hist.txt

gives me no file names, but rather a commit info.

P.S. I am also using TortoiseGit.

PPS. I tried to use answers from following question: Git: How to search for a deleted file in the project commit history? and they didn't help me. I just want the practical result (an advice that everybody could take as it is and it will work).

Paul
  • 25,812
  • 38
  • 124
  • 247
  • This is one of the many reasons I like using `tig`. – mattliu Dec 06 '16 at 12:21
  • Possible duplicate of [Git: How to search for a deleted file in the project commit history?](http://stackoverflow.com/questions/7203515/git-how-to-search-for-a-deleted-file-in-the-project-commit-history) – Joe Dec 06 '16 at 13:08
  • Joe thank you, but I tried to use that question with answers and they didn't help me. – Paul Dec 06 '16 at 13:26
  • You should *quote* the `**/thefile.*` pattern, lest your shell eat the asterisks and do something on its own with them. (This probably should be in that other post. Some shells will eat them and some won't and it sometimes depends on whether there are matches for `**/thefile.*`, so without the quotes it will *sometimes* work, which makes things extra-mysterious.) – torek Dec 06 '16 at 17:33

1 Answers1

1

you can use command git log --follow --oneline <complete file name> it will give you commit number, description. If you remove --oneline, you will get date time also

with commit number you can checkout the file in detached head mode

Update

The output of git log --follow --oneline MyFile.txt is as follows:

fatal: ambiguous argument 'MyFile.txt': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

yes, because you haven't given full path name of file, MyFile.txt, it must be from root folder of the git. you can find root folder by git rev-parse --show-toplevel