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