2

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?

Quick doodle of commits/branches cherry pick desirted

Pxtl
  • 880
  • 8
  • 18
  • What do you mean "future commits"? Will you give a diagram of an example git history? – Code-Apprentice Feb 01 '22 at 16:10
  • Commits on the left branch (after the picked ones) will not be integrated on the right branch. Nether at the cherry piking operation or on new commits (on the left branch). – Orace Feb 01 '22 at 16:54
  • No, what I'm asking is "which of those follow-up commits are bug-fixes to the red commit". Which of the 3 follow-up commits impact the same code as the red commit, and are therefore potential fixes that I should examien further. – Pxtl Feb 01 '22 at 17:07
  • I assume your "unstable dev branch" actually points at the top-most yellow commit. And "stable release branch" refers to the topmost green commit. Is this correct? If so, your labelling illustrates a fundamental misunderstanding of how branches work: a branch always points at the latest commit in the history for that branch and contains all commits from there to the root. It is common to think of a branch as beginning where it diverges from a common trunk, but this is incorrect. – Code-Apprentice Feb 01 '22 at 17:14
  • Yes I'm aware branch points at head. – Pxtl Feb 02 '22 at 12:35

1 Answers1

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.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268