Learn how to check changed files in a commit with step-by-step Git commands—from using git log and git show to GitHub’s web interface.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
Step 1: Open your terminal or Git Bash
Before running any Git commands, you need a terminal on your system:
Git Bash
or Command Prompt if Git is in your PATH.Terminal
.
Step 2: Navigate to your local repository
Change the working directory to the folder where your Git repository is located.
cd /path/to/your-repo
Replace /path/to/your-repo
with the actual path on your machine.
Step 3: View the commit history to identify the target commit
Use git log
to list recent commits along with their SHAs, authors, dates, and messages:
git log --oneline
You’ll see output like:
a1b2c3d Fix typo in README
e4f5g6h Add user authentication
i7j8k9l Update styles for header
Copy the SHA (e.g., a1b2c3d
) of the commit you want to inspect.
Step 4: List changed files with git show --name-only
Once you have the commit SHA, you can display which files changed in that commit:
git show --name-only a1b2c3d
This prints the commit details followed by a list of file paths that were added, modified, or deleted.
Step 5: See file change stats with git diff --stat
To view a summary of insertions and deletions per file, run:
git diff --stat a1b2c3d^!
Example output:
README.md | 10 +++++++---
src/app.js | 5 +++--
src/styles.css | 12 ++++++++++--
3 files changed, 19 insertions(+), 8 deletions(-)
Step 6: Drill down into specific file diffs with git show
If you want to inspect the specific line changes in each file, simply run:
git show a1b2c3d
This shows the full diff of added (+) and removed (−) lines.
Step 7: Use git diff-tree
for scripting
For automation or scripts, git diff-tree
can output only filenames in machine-readable format:
git diff-tree --no-commit-id --name-only -r a1b2c3d
Or to include change types (A = added, M = modified, D = deleted):
git diff-tree --no-commit-id --name-status -r a1b2c3d
Step 8: Check changed files on GitHub’s web interface
Step 9: Filter changed files by pattern
If you want to see changes only for certain file types (e.g., .js
files), combine with grep
:
git show --name-only a1b2c3d | grep ".js$"
This limits the output to JavaScript files only.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.