'How do I find other commits that touch the same code as a given commit?
I'm looking to cherry-pick some code. The code was squashed-on-merge, so I know it's just that one commit to get the feature or bugfix that I desire.
However, I'm worried that this commit may introduce its own bugs. Presumably, those bugs were spotted and fixed on the main branch. So I'd like to see a list of future commits in the same branch that touch the same code, to find bugfixes to the main commit. How do I do that?
Solution 1:[1]
You can use combinations of git log and git blame to find the information you are looking for. A good first start is to do git blame -- <filename> this will show which commits changed each line of a file. You can also do git log <branch> -- <filename> to see a history of commits that changed a given file. Fore more details check out git help blame and git help log.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Code-Apprentice |

