Distil git logs attached to a single file

Redowan Delowar June 21, 2022
Source
I run git log --oneline to list out the commit logs all the time. It prints out a compact view of the git history. Running the command in this repo gives me this: However, there are times when I need to list out the commit logs that only represent the changes made to a particular file. Here's the command that does exactly that. Running the command on the Markdown file that you're currently reading prints out the following: Unfortunately, this command doesn't support flag chaining. So, you can't use the --follow flag multiple times to concatenate the logs for multiple files. But there's a way to do it via shell command. Here's how: Running the command on two random files in this repo yields the following output: Here, the first xargs is used to split the line and extract the two filenames. The second xargs applies the git log --oneline --follow command to the two files and concatenates the output with a ==== separator. The separator helps you figure out which output came from which file.

Discussion in the ATmosphere

Loading comments...