dimestorecoffee
dimestorecoffee

Reputation: 41

How will a branch off a branch look like when I do git branch -a?

If I do "git branch -a" in my terminal, does a branch of a branch (so a branch I made off of another branch) look different from a branch off of origin? For example, if I have a branchB off of branchA, should the branch look like: origin/branchA/branchB?

Upvotes: 2

Views: 38

Answers (2)

VonC
VonC

Reputation: 1323343

The reasons branchB does not appear as branchA/branchB are:

  • that would imply some kind of strong coupling between branchA and branchB, which makes no sense considering:

    • branchA can be deleted at any time (that won't delete the commits it referenced): branchB would still be there, unchanged
    • branchB can be rebased at any time on top of any other branch
    • branchB has no knowledge of any other branch it is "based" upon: it only references a commit (and all commits reachable from its HEAD)
  • a slash is allowed in a branch name: you can name it xxx/yyy (as one branch): this is for defining a hierarchy in a branch naming convention.
    Typical examples:

    • Gerrit branches for review: refs/for/REL1_20/bug/36151: the for/REL1_20/bug/36151 is one (Gerrit) branch.
    • GitHub Pull Request branches: git fetch origin pull/ID/head:BRANCHNAME: pull/ID is one (PR) branch

Upvotes: 2

hobbs
hobbs

Reputation: 239722

No.

Unless you name it that, anyway. All that is displayed is the branch's name, which can be anything you want.

Upvotes: 2

Related Questions