How to Display Filenames Changed in All Commits

John Wachira Mar 04, 2025 Git Git Log
  1. Using git log to Show Filenames Changed in All Commits
  2. Using git diff to Show Filenames Changed in All Commits
  3. Using git log with Custom Formatting
  4. Conclusion
  5. FAQ
How to Display Filenames Changed in All Commits

Git is an essential tool for version control, allowing developers to manage changes in their code effectively. One common question that arises among Git users is how to display the filenames that have changed in all commits. Understanding this can provide valuable insights into your project’s history and help in tracking modifications over time.

In this article, we will explore various methods to display filenames changed in commits using Git commands. Whether you are a novice or an experienced developer, this guide will help you navigate through the process seamlessly. Let’s dive into the world of Git and uncover how to view those important filenames.

Using git log to Show Filenames Changed in All Commits

The most straightforward method to display filenames changed in all commits is by utilizing the git log command. This command provides a comprehensive history of commits and can be customized to include specific details, such as filenames. Here’s how you can achieve this:

git log --name-only

When you run this command, you will see a list of commits along with the filenames that were modified in each commit. The --name-only option ensures that only the names of the files that were changed are displayed, making it easier to focus on the modifications without the clutter of commit messages.

Output:

commit 8b3c1f0e3d4f6b1d1e2e6f8c5e5f8e0e3d4f6b1d
Author: Jane Doe <jane@example.com>
Date:   Mon Oct 2 14:00:00 2023 +0200

    Updated README file

README.md

commit 7a2c1f0e3d4f6b1d1e2e6f8c5e5f8e0e3d4f6b1c
Author: John Smith <john@example.com>
Date:   Sun Oct 1 10:00:00 2023 +0200

    Fixed bug in main.py

main.py

This output illustrates the commit history, along with the filenames that were changed in each commit. It’s a great way to get a quick overview of your project’s evolution.

Using git diff to Show Filenames Changed in All Commits

Another effective way to display filenames changed in all commits is through the git diff command. This command can show differences between various commits, including the files that were added, modified, or deleted. Here’s how to use it:

git diff --name-only HEAD~5 HEAD

In this example, we are comparing the last five commits to the current HEAD. The --name-only option will list only the names of the files that have changed. If you want to see the filenames for all commits, you can adjust the range accordingly.

Output:

README.md
main.py
utils.py

This output provides a concise list of filenames that were modified between the specified commits. It’s particularly useful when you want to focus on recent changes without scrolling through the entire commit history.

Using git log with Custom Formatting

For those who prefer a more tailored output, the git log command can be customized with formatting options. By using placeholders, you can display specific commit details alongside the filenames. Here’s a command that achieves this:

git log --pretty=format:"%h %s" --name-only

In this command, %h represents the abbreviated commit hash, and %s is the commit message. This allows you to see both the commit details and the filenames changed in a single view.

Output:

8b3c1f0 Updated README file
README.md

7a2c1f0 Fixed bug in main.py
main.py

This output format is particularly useful for reviewing commit messages alongside the associated files. It provides context, allowing you to understand why certain files were modified.

Conclusion

Displaying filenames changed in all commits is a fundamental aspect of using Git effectively. By utilizing commands like git log, git diff, and customizing your output, you can easily track modifications and understand the evolution of your codebase. Whether you are managing a small project or a large codebase, these methods will enhance your ability to navigate through your commit history efficiently. Embrace these techniques, and you’ll find that monitoring changes in your files becomes a breeze.

FAQ

  1. How can I see all commits in a Git repository?
    You can use the command git log to view all commits in your Git repository.

  2. Is there a way to see changes made in a specific file?
    Yes, you can use git log – to see the commit history for a specific file.

  3. Can I filter commits by author?
    Yes, you can use git log –author=“Author Name” to filter commits made by a specific author.

  4. What does the –name-status option do in git log?
    The –name-status option in git log shows the status of files (added, modified, deleted) alongside their names.

  5. How can I check the changes made in the last commit?
    You can use git show to see the changes made in the last commit.

Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
Author: John Wachira
John Wachira avatar John Wachira avatar

John is a Git and PowerShell geek. He uses his expertise in the version control system to help businesses manage their source code. According to him, Shell scripting is the number one choice for automating the management of systems.

LinkedIn

Related Article - Git Log