(git) log for file/directory

This commit is contained in:
scbj
2026-05-18 10:55:40 +02:00
parent d90e47a678
commit d535961515
+25
View File
@@ -12,14 +12,19 @@ findings.
- [glossary](#glossary)
- [branches](#branches)
- [create a branch](#create-a-branch)
- [delete a branch](#delete-a-branch)
- [submodules](#submodules)
- [update reference](#update-reference)
- [show only names of changed files on `show` or `diff`](#show-only-names-of-changed-files-on-show-or-diff)
- [stash](#stash)
- [fixup](#fixup)
- [removing files from the index](#removing-files-from-the-index)
- [list commits that changed a file or directory](#list-commits-that-changed-a-file-or-directory)
- [philosophies](#philosophies)
- [merge](#merge)
- [rebase](#rebase)
- [squash](#squash)
- [tags](#tags)
<!--toc:end-->
@@ -128,6 +133,26 @@ git rm --cached <file-name>
This is helpful if one accidentally committed autogenerated files.
## log for file or directory
To show the commits that changed a file use
```sh
git log --follow <filename>
```
For a directory use
```sh
git log <path>
```
The latter struggles when a files was renamed, so for specific files
it is recommended to use the first command.
For directories, or when sure that the file was not renamed, the
second command is easier.
## philosophies
Important things to always remember: