简体   繁体   中英

Inexplicable 'git merge-base' result

I have a branch whose head is at '65d26ca19a93a510356a9bf661213567b213c9e8'.

I'm unable to understand why git merge-base between master and this commit is pointing to this commit itself.

$ git merge-base master 65d26ca19a93a510356a9bf661213567b213c9e8
65d26ca19a93a510356a9bf661213567b213c9e8

Parents for the branch head is as follows:

$ git rev-list --parents -n1 65d26ca19a93a510356a9bf661213567b213c9e8
65d26ca19a93a510356a9bf661213567b213c9e8 febad34b7278dbbf7fd994192db6ae1f595288e6

I have another branch in the same repo, whose head is at 'c1f9401c828160c20b38402852d502ae2fe41b7f'

For this branch, 'git merge-base' is returning expected result (which is a commit in the master branch) while 'git rev-list' behavior is same as what is seen for the branch I'm have trouble with

$ git merge-base master c1f9401c828160c20b38402852d502ae2fe41b7f
d3706c9e9447fea39a3f34087027fdbb6d561b2e


$ git rev-list --parents -n1 c1f9401c828160c20b38402852d502ae2fe41b7f
c1f9401c828160c20b38402852d502ae2fe41b7f d3706c9e9447fea39a3f34087027fdbb6d561b2e
$ git merge-base master 65d26ca19a93a510356a9bf661213567b213c9e8
65d26ca19a93a510356a9bf661213567b213c9e8

For this case, there are two possibilities.

  1. master points to 65d26ca19a93a510356a9bf661213567b213c9e8 .
  2. 65d26ca19a93a510356a9bf661213567b213c9e8 is an ancestor of master .

By git log --oneline --graph --decorate master , check if you can see 65d26ca in the list.

You can also check if 65d26ca is reachable from master by git branch -a --contains 65d26ca .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM