4

We have four branches Branch A, B, C, D. Branch C is created from Branch A and Branch D is created from Branch B. We make changes to Branch D and merge them into Branch B. The same changes we cherrypick from Branch D to Branch C and merge into Branch A.

Now we want to list the names and paths of files changed in Branch A because of above behavior.

I have tried my best and now seeking your help. Thanks in advance

jon
  • 213
  • 1
  • 5
  • 18

1 Answers1

1

So you start (assuming A and B were created from master) with:

           d--d--d
          /
       b--b--b--b--b--b
      /
  m--m
      \
       a--a--a--a
              \
               c--c--c

You merge and cherry-pick:

           d--d--D
          /       \
       b--b--b--b--b--b
      /
  m--m
      \
       a--a--a--a------------------A
              \                   /
               c--c--c--d'--d'--d'

Try first by listing the files originally modified in branch D (with D being the commit just before merging back to A)

 git diff --name-only A...D
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Hi Von - the problem with this approach is branch A and B are constant. But branch C and D are dynamic. Is there any option to compare the files between A and B and check if they have any common ancestor commit – jon Jul 02 '19 at 05:18
  • @jon `git merge-base A B` would identify the common ancestor – Romain Valeri Jul 02 '19 at 05:30
  • can we also get the file names ? – jon Jul 02 '19 at 06:19
  • @jon a `git ls-tree -r` of the commit returned by `git merge-base A B` should hep. – VonC Jul 02 '19 at 06:52
  • Hi Von- its not working. Is there any way to find the common files changed between branch A and branch B since specific date. – jon Jul 02 '19 at 09:48
  • FYI branch B is created from branch A and my job is to figure out the list of changed files in branch A and the same change should exist in branch B – jon Jul 02 '19 at 10:01
  • @jon Start with https://stackoverflow.com/a/4949604/6309: `git diff --name-status A..B` – VonC Jul 02 '19 at 10:46