From d5359615155932bf3160ad24ad7df6aa6306d5b9 Mon Sep 17 00:00:00 2001 From: scbj Date: Mon, 18 May 2026 10:55:40 +0200 Subject: [PATCH] (git) log for file/directory --- git.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/git.md b/git.md index 25d0206..79d0d87 100644 --- a/git.md +++ b/git.md @@ -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) @@ -128,6 +133,26 @@ git rm --cached 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 +``` + +For a directory use + +```sh +git log +``` + +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: