Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

236
Views
How to know which files have been modified to fix a bug starting from a git commit?

I'm working on a Java project and I need to understand which files have been modified to fix bugs.

The versioning of the project I'm working on is managed through Git.

Until now I have been able to get the commit that was made to fix the bug, however starting from this how can I get the files that have been modified?

I probably have to run the diff between the commit that was made to fix the bug and another commit, but what is this other commit? Can I get it by going up the commit graph? If so, how?

All this has to be done in Java ... to interact with GitHub I'm using the jgit library.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can use the git diff with --name-only flag comparing two commits to check the changes between them.

For example, if you want to compare the changes in the last 5 commits you can use HEAD reference by doing:

git diff --name-only HEAD HEAD~5

where the first commit reference is the newest one.

If you want to compare the changed files from a specific commit with the HEAD commit, you can get it by doing:

git diff --name-only HEAD 8614c3d70397f03ab504de8d23e8255d52fa3ed1

where 8614c3d70397f03ab504de8d23e8255d52fa3ed1 is your commit hash by example.

For your application specifically

Since you want to check the file that was changed in one specific commit, you can do using the same logic by doing:

git diff --name-only COMMIT_HASH COMMIT_HASH~1

So if the bugfix commit has the hash 8614c3d70397f03ab504de8d23e8255d52fa3ed1 for example, you can check the files changed in this commit by doing:

git diff --name-only 8614c3d70397f03ab504de8d23e8255d52fa3ed1 8614c3d70397f03ab504de8d23e8255d52fa3ed1~1

over 4 years ago · Santiago Trujillo Report

0

To see the files ghat were modified on a revision you can do

git show --name-status some-revision

You can also specify --name-only instead of --name-status

git diff also works but it's mostly used for ranges because if you want to use diff and only provide a single revision as a param, you end up comparing with your current working tree so you end up having to pass in 2 params when, as in your case, you want to check files modified by a single revision.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!