1

When i do git log --oneline in my local repo i see m/master as a branch what does m/master mean here? Does that represent my local master branch.

$ git log --oneline
7c5a48b (HEAD -> default, origin/featureBranch, origin/master, m/master, master) commit xyz changes
.
.
.

Also i see HEAD pointing to default, is default another branch? Is default a standard default branch ? I thought master was default standard branch as i can see both master and default as branches ?

3
  • Are you using repo init and repo sync to download the repositories?
    – ElpieKay
    Aug 19, 2020 at 7:34
  • yes @ElpieKay I am using repo init and repo sync
    – Jack
    Aug 19, 2020 at 7:39
  • 1
    yes default is another branch and that's even the one currently checked out (that's why HEAD is pointing toward it)
    – Philippe
    Aug 19, 2020 at 8:39

2 Answers 2

7

m/master is a special ref used by the repo tool. Its full name is refs/remotes/m/master. Although it uses refs/remotes, it's not a real remote tracking branch like origin/master. The repository doesn't have a remote named m.

To initialize a repo workspace, we use

repo init -u <url_to_manifest_repo> -b <branch> -m <path_to_manifest>

-b <branch> instructs repo to checkout <branch> after cloning the manifest repository. If it's omitted, it defaults to -b master. But the repo tool creates refs/heads/default in replacement of refs/heads/<branch>. The master also exists in your case, because master does exist in the remote repository and has once been checked out or created in the local repository.

The repo tool creates refs/remotes/m/<branch> for every project defined in <path_to_manifest> and for the manifest repository. In your case, it's m/master. If you use -b foo, it would be m/foo. In the manifest repository, the value of m/<branch> is refs/remotes/origin/<branch>. In the project repositories, its value is refs/remotes/origin/<upstream> or refs/remotes/origin/<revision>. upstream and revision are defined in the manifest.

1
  • This answer was useful, but it wasn't immediately obvious to me why this ref was created. Now I see that I can be in any git repository in the repo, and they can each have their own set of unique branches, but I can always get back to what the manifest specifies by checking out m/<path_to_manifest> instead of having to look it up in the manifest and manually check it out.
    – gsgx
    Apr 23, 2022 at 6:50
2

It could mean a number of things.

You probably have a remote called m which has a branch called master that points to that commit.

You might have a branch or tag called m/master that points to that commit.

Or generally speaking, you might have a reference called m/master that's pointing to that commit.

Hard to tell from the text alone. Git would show the references in different colors so you could tell the difference. You can verify by looking at the .git/refs folder and looking for that master branch or potentially the .git/packed-refs file if that exists. Or more directly, you can list all refs with git show-ref so you can see where that ref might exist. Depending on where it is in the refs folder determines what kind of reference it is.

2
  • Can you point out to some documentation around the first line HEAD -> default, origin/featureBranch, origin/master, m/master, master? What does the general output represent? Aug 19, 2020 at 7:45
  • 1
    It is probably documented, I just wouldn't know where to look. You could try digging through the online book. But from my understanding, of the different special types of references, the prefixes are removed when named. Such as branches (refs/heads/), tags (refs/tags/), remote branches (refs/remotes/), and so on. Other references will be shown in full. Aug 19, 2020 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.