When I use git-p4 sync to add additional p4 branches to a p4 repository I've created using git-p4 clone, they show up as remote branches, e.g. remotes/p4/p4branchname. So they're not really "in" my local repo, meaning I can't push them, and I can't even check them out without entering the dreaded "detached HEAD" state.
But these branches are local to my machine. So what does it mean for them to be "remote", and are there recommended steps to make them more normal so I can work with them?
The way your local Git works for syncing with a remote Git is by maintaining mirror branches that reflect the remote Git (updated whenever you fetch, pull, or push). These are called remote-tracking branches, and their names start with the name of the remote, possibly preceded by the name
remotes, and followed by a slash.You are absolutely correct that they are "local" to your machine in the sense that they are on your machine. But they are not local branches. They do not belong to you, and you cannot (as you have rightly said) check them out, except in detached head mode as a way of studying them. Their only purpose is to maintain this synchronized mirrored reflection of the remote Git. And this makes sense, for safety. Git will never touch your branches, the local branches, based on the remote Git, unless you specifically ask it to (e.g. by merging or pulling a remote branch into a local branch).
The way to work with respect to a remote-tracking branch is to start a local branch from the remote-tracking branch. For example:
That creates a local branch, starting at the remote-tracking branch, and checks it out so you can actually get work done. There are shortcuts for saying that kind of thing, but I recommend using the full version so that you know what you're doing.