Reputation: 2664
I know this question has already been asked here but I'm just having some weird problem that I would like to solve with your help.
So I've got a branch named feature-kernel
that I would like to fork from and I want to create feature-new-feature
. So here's what I did while staying on some third branch:
git checkout -b feature-new-feature feature-kernel
git push --set-upstream origin feature-new-feature
Then I checked my bitbucket and in Branches it shows that the parent branch of the feature-new-feature
branch is master
.
How is this possible? What am I doing wrong?
Upvotes: 1
Views: 538
Reputation: 5855
Branches in git are just pointers to commits. There is no trace left of how given branch was created (well, maybe sometimes in local reflog, but it's unreliable and never pushed). So from git's point of view feature-new-feature
and feature-kernel
are two identical branches, only difference being name.
The Bitbucket visualization shows the current relation in (commits) history, but then it has to show feature-new-feature
and feature-kernel
in just the same way, as stemming from the branch somewhere behind them - in that case, master
.
I also think that the branch shown in branch view as parent branch is always either main branch (master
) or the branch you create a pull request to, and not just "whatever branch is closest". To see real relation between branches, use commits view (in Bitbucket), or gitk
, or equivalent.
Upvotes: 2
Reputation: 3596
If you did NOT do any change to your new branch feature-new-feature
after branching from feature-kernel
, i.e. branch feature-kernel
and branch feature-new-feature
are the same, git will see these two branch as the same one, and they will share the same parent branch. If feature-kernel
is branched from master
branch, you will see feature-new-feature
branched from master
branch too.
Upvotes: 1