0

If I'm looking at a given file in the main branch on GitHub on a busy project, is there a way to identify all the branches and PRs that contain changes to this file that have not been merged into main (or whichever branch I'm looking at)?

I often run into this problem when I'm looking at a bug, etc., in some code and I want to see whether it's been fixed somewhere already, before attempting to tackle it myself.

I know I can clone the repo and run a few steps, but (a) I want to know if there's a simpler way to do it that I'm missing out on and (b) this doesn't cover pull requests from forks, which is the more likely scenario for a lot of projects.

My current approach is just to browse the PRs (and issues) and see if there's anything that has a description that looks related, but when there are dozens of PRs, that's… sub-optimal. It would solve the problem much, much faster (and more thoroughly) if there were a way to see all the PRs and branches that have changes to that particular file, and I'm curious if I've missed a way to do this.

  • AFAIK commits, branches, and PRs do not contain changes in git. They're snapshots of all files in the repo. Changes between commits/branches/PRs are calculated by `git diff` commands and the like. – evolutionxbox Feb 03 '23 at 16:34
  • I can't think of a better way than looping over the branches of all remotes (including forks) and `git diff`ing to the main branch; you can make `git diff` show just the list of modified files and could write a little script that checks if the file you're interested is in that list. – Benjamin W. Feb 03 '23 at 16:42

0 Answers0