0

I'm creating a new branch through gitlab.

enter image description here

How can i get the commit(hash code) information of branch pack that was used to create branch test through git commands/ gitlab API ?

  • 2
    Git does not retain that information. A branch name holds a commit hash ID. If you stuff a new, different commit hash ID into the branch name, now it holds the new different hash ID. It does not remember the old one. So branches have no "creation", they just exist or don't. (Git *does* have optional "reflogs", which aren't really the same as history, but can serve in a pinch. I don't think you can get to those from the GitLab API but I'm not a GitLab user.) – torek Oct 28 '22 at 09:08
  • Torek is right about that. If the downstream branch has not been rebased _nor_ has been merged with later commits of the upstream branch (and that's a big **if**), you could get that with `git merge-base downstream-branch upstream-branch`. – eftshift0 Oct 28 '22 at 09:11
  • @torek how can i know from which hash or commit my branch was created from? or can i get only the list of commits that occured to my initial branch ? – Ahmed Abdeljelil Oct 28 '22 at 09:43
  • The short answer is "you can't". The name names a commit, and that's all you're allowed to know. Git decrees that this is all you *need* to know. And that's mostly true! – torek Oct 28 '22 at 09:45
  • Does this answer your question? [Finding a branch point with Git?](https://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git) – Madhu Bhat Oct 29 '22 at 20:48

0 Answers0