GIT - How to know the branch a branch branched from? -
GIT - How to know the branch a branch branched from? -
support create multiple branches (aaa, bbb, ccc) commit. then, create new branch (ddd) 1 of branch (bbb) , create commit on it.
then pushed remote. how person knows new branch (ddd) comes branch?
the git commands did was:
git branch aaa git branch bbb git branch ccc git branch ddd bbb git checkout ddd echo 2 >> file git add together file git commit -m "2"
and git log show
* commit d259a3b (head, ddd) | | 2 | * commit efb038c (develop, ccc, bbb, aaa) | | 1 | * commit dd24bb6 (master)
it possible know ddd branched bbb?
thanks
it indeed impossible in general. git records only1 single commit-id (sha-1) reference name (such branch or tag) points. history of commit determined solely commit's parent ids, not record branch-names. when force remote, "push" operation sends sha-1 of commit you're pushing (plus more sha-1s other linked objects—trees , files, parent commits, etc—plus contents of objects, needed based on what's missing on remote), , asks remote set its branch point new sha-1.
in other words, tell remote: "here, have commit 1234567, , set branch label ddd
= 1234567". may tell "to need 5 other commits", 1 of have labeled bbb
, if don't tell remote "oh way set label bbb
other commit too" won't have info anywhere.
1this bit of overstatement: git records, in reflog, each sha-1 stored in label, including branch labels. hence possible walk through label's history "figure out started". there 2 limits on though: reflogs purely local, never transmitted fetch or push; , reflogs expire, after 90 days in these cases (although configurable , there additional complexities). long there's force step, or allow more 3 months pass, there's no way tell.
git git-branch
Comments
Post a Comment