1

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?

8
  • First, git branch does not have the option -b. Maybe you mean git checkout -b feature-new-feature feature-kernel? Second, Git does not have the concept of parent branch although I understand what you mean by it. If feature-kernel and master happened to point to the same commit when feature-new-feature was created, then we can say both feature-kernel and master are "parent branches". Commented May 8, 2018 at 7:48
  • @ElpieKay oh oh my bad, yeah I meant git checkout -b Give me a sec to realise it Commented May 8, 2018 at 7:51
  • Another thing to check. Is your local "feature-kernel" up to date? If there were extra commits on this branch that you didn't have locally, then your new branch will be based on the older commits. Commented May 8, 2018 at 7:55
  • @ElpieKay Well no, they didn't point to the same commit when the new branch was created, so as far as I can see, there must be the only parent which is 'feature-kernel', right? But when I go to bitbucket and then to branches and looked at the scheme I can clearly see that my newly created branch springs from the master branch. Or I just misinterpret the scheme? Commented May 8, 2018 at 7:59
  • 1
    Please bear in mind that forking has a very specific meaning and does not refer to refer to a git concept, but rather a github one. help.github.com/articles/fork-a-repo Commented May 8, 2018 at 9:06

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.