Showing Which Files Have Changed between Two Revisions

Better Stack Team
Updated on June 24, 2024

To show which files have changed between two revisions in Git, you can use the git diff command with the --name-only option. Here's how you can do it:

 
git diff --name-only <commit1> <commit2>

Replace <commit1> and <commit2> with the commit hashes, branch names, or any other valid Git references representing the two revisions you want to compare.

For example, to see which files have changed between the commits referenced by master and develop branches, you would run:

 
git diff --name-only master develop

This command will output a list of files that have changed between the two specified revisions.

Note:

  • The -name-only option tells Git to show only the names of the changed files, without displaying the actual content changes.
  • If you want to see the content changes within the files as well, you can omit the -name-only option from the command.
  • This command is useful for getting a quick overview of the changes between two revisions, especially when you're interested in knowing which files have been modified, added, or deleted.
Got an article suggestion? Let us know
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