Home How to track changes in a specific file in git

How to track changes in a specific file in git

It’s been a long time since I’ve written a blog post, but today I found something I’ll be definitely using a lot in the future.

While working with jenkins I found out that a pipeline that used to work, suddenly started complaining about some syntax. However, the job was running, the syntax was actually a faulty shell invocation, so I wen’t to bitbucket to check on for commits that affected that file, that caused it to start complaining about syntax.

Forget searching for commits there, I wanted to search for a specific file, so I guess since this a git dedicated day ( some issues before with some detached heads on merging in Jenkins), I decided to learn a little more as well regarding git ( man I love git more and more everyday)

Ok forget the intro.

You are here because you want to know How to track changes in a specific file in git.

This is a command line usage. I don’t use other tools to interact with, besides the web interface at bitbucket, and others and the visual studio code to add and commit changes. All pushes, merges and others take place at the terminal with the git cli.

    git log --follow -p file-to-track

This is a filter to the git log, and shows you diffs according to all changes at current branch and their authors.

This was specially useful tracking down a missing shebang, causing the syntax tou pop out, given some bashisms on the sh invocation of jenkins.

This post is licensed under CC BY 4.0 by the author.