{
  "$type": "site.standard.document",
  "canonicalUrl": "https://rednafi.com/misc/distil-git-logs-attached-to-a-file/",
  "description": "View git commit history for a single file with git log --follow. Learn to track multiple files with xargs and concatenate their commit logs.",
  "path": "/misc/distil-git-logs-attached-to-a-file/",
  "publishedAt": "2022-06-21T00:00:00.000Z",
  "site": "at://did:plc:fgtm2c26vfcj74rfmeggbyqj/site.standard.publication/3mnl6f7ob462z",
  "tags": [
    "Shell",
    "Unix",
    "Git",
    "TIL"
  ],
  "textContent": "I run git log --oneline to list out the commit logs all the time. It prints out a compact\nview of the git history. Running the command in this repo gives me this:\n\nHowever, there are times when I need to list out the commit logs that only represent the\nchanges made to a particular file. Here's the command that does exactly that.\n\nRunning the command on the Markdown file that you're currently reading prints out the\nfollowing:\n\nUnfortunately, this command doesn't support flag chaining. So, you can't use the --follow\nflag multiple times to concatenate the logs for multiple files. But there's a way to do it\nvia shell command. Here's how:\n\nRunning the command on two random files in this repo yields the following output:\n\nHere, the first xargs is used to split the line and extract the two filenames. The second\nxargs applies the git log --oneline --follow command to the two files and concatenates\nthe output with a ==== separator. The separator helps you figure out which output came\nfrom which file.",
  "title": "Distil git logs attached to a single file"
}