I have a bunch of commits in the repository. I want to see a list of files changed between two commits - from SHA1 to SHA2. What command should I use?

 

To see a list of files changed between two commits in a Git repository, you can use the git diff command followed by the two commit hashes (SHA1 and SHA2). Here's the command with an example:

bash
git diff SHA1 SHA2 --name-only

Replace SHA1 and SHA2 with the actual commit hashes you want to compare.

Here's a step-by-step example:

  1. Identify the SHA1 and SHA2 commit hashes that you want to compare. You can find them using git log or other Git history viewing commands.

  2. Run the git diff command with the commit hashes:

bash
git diff abcd1234 efgh5678 --name-only

In this example, replace abcd1234 with the SHA1 commit hash and efgh5678 with the SHA2 commit hash.

  1. The --name-only option is used to display only the names of the files that changed between the two commits. If you want more detailed information about the changes, you can omit this option.

The command will list the files that have changed between the two specified commits, showing their names. This is useful for getting an overview of the changes between those two points in the Git history.

Comments