Is there anyway to check the get the history of what has happened at a particular path in Git, one that may now be deleted or have been moved?
Asked
Active
Viewed 28 times
0
-
1For a single file, try `git log --follow --
`. – jub0bs Sep 04 '21 at 16:32 -
2Note that the *only* history *in* a repository is the set of commits in the repository. What `git log --follow` does—it's the right answer for the question as you asked it—is to look for commits where, between that commit and its parent, that particular path name *changed* somehow. If the change was "rename the file", it starts looking at the previous name, from that point back. – torek Sep 04 '21 at 18:26
-
@jub0bs Not a file or a folder, but the path. – Melab Sep 05 '21 at 00:47
-
@torek That's not what I want. I need to find out when something existed at particular path. – Melab Sep 05 '21 at 00:49
-
3Then leave out `--follow`, and Git *won't* change which path it's looking for, even if the file seems to be renamed. As the file comes and goes at that path, or gets changed at that path, `git log` will show each such commit. (All `--follow` does is make Git follow renames. This has certain limitations, since Git doesn't actually record renames: it just *guesses*, based on the commits.) – torek Sep 05 '21 at 01:18
-
2Meanwhile: I'm not sure what distinction you're trying to make between "path" and "file or folder" here. A path like `path/to/file` or even `path/to` is just a pathspec, as far as `git log` is concerned. The `--follow` trick, which tries to follow renames, only works with one *file* name, but `git log` works with arbitrary pathspecs here. – torek Sep 05 '21 at 01:21
-
See also : [History of a file](https://stackoverflow.com/questions/53611635/git-history-of-a-file), [Show history of a file](https://stackoverflow.com/questions/9807393/show-history-of-a-file), [View the change history of a file using Git versioning](https://stackoverflow.com/questions/278192/view-the-change-history-of-a-file-using-git-versioning) ... – LeGEC Sep 07 '21 at 07:45