This repository contains a Bash script that performs git diff
requests file by file. The script compares two specified commits or branches and displays the diff for each file that has changed between them.
-
Clone the repository and navigate to the directory where you want to use the script:
git clone <repository-url> cd <repository-directory>
-
Place the script in the root directory of your Git repository or any directory within the repository where you prefer to run the script. For example:
cp git_diff_files.sh /path/to/your/git/repository/
-
Navigate to your Git repository:
cd /path/to/your/git/repository/
-
Make the script executable:
chmod +x git_diff_files.sh
-
Run the script with two commit hashes or branch names as arguments:
./git_diff_files.sh <commit1> <commit2>
To compare changes between two branches, main
and feature-branch
:
./git_diff_files.sh main feature-branch
To compare changes between two specific commits:
./git_diff_files.sh commit1_hash commit2_hash
The git_diff_files.sh
script does the following:
- Checks if the correct number of arguments (two) are provided. If not, it prints a usage message and exits.
- Retrieves the list of files that have changed between the two specified commits or branches using
git diff --name-only
. - Loops through each changed file and displays the diff for that file using
git diff
.
- Git must be installed and available in your system's PATH.
- The script should be run in a Git repository.
This script was created to simplify the process of reviewing changes file by file in a Git repository.