View the Change History of a File Using Git Versioning

Better Stack Team
Updated on June 24, 2024

To view the change history of a file using Git versioning, you can use the git log command with the --follow option followed by the filename. This will show the commit history of the file, including renames.

Here's the command:

 
git log --follow <file>

Replace <file> with the name of the file for which you want to view the change history.

Additionally, you can use other options with git log to customize the output. For example, you can use --oneline for a more concise output, --stat to see statistics about changes in each commit, or --graph to visualize the commit history as a graph.

For a more detailed view, you can also use a graphical Git client like GitKraken, Sourcetree, or GitHub Desktop, which often provide easier ways to explore the commit history of individual files and visualize changes over time.

Got an article suggestion? Let us know
Explore more
Git
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github