1

There are two branches master and A. I know that some work has been done in the branch A a long time ago. Whoever was working on that branch, merged the master branch into the branch A, then merged the branch A to the master. All the branched are in remote. Now how i can find the commits that originally come from branch A?

N.B I am not looking for the branch name of certain commit. Rather I have the branch name and I am looking for the commits, so please don't mark it duplicate with this or other similar question

mahfuj asif
  • 1,691
  • 1
  • 11
  • 32
  • In Git before 2.36, this is pretty hard to do well in general. The new feature in 2.36 makes it easy *if* whoever built the branch obeyed some simple (easy to obey) rules, but without that Git version, your best bet is probably just to run `git log --graph` and try to follow the original branch's commits "by hand". – torek Jun 22 '22 at 09:41

1 Answers1

2

As described in "Finding a branch point with Git?", that should be possible with Git 2.36 (Q2 2022):

(branch_A_tag)
     |
--X--A--B--C--D--F  (master) 
      \   / \   /
       \ /   \ /
        G--H--I--J  (branch A)
vonc@vclp MINGW64 ~/git/tests/branchOrigin (branch_A)
git rev-list --exclude-first-parent-only ^master branch_A

That will give you J -- I -- H -- G, which are the commits that originally come from branch A.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250