I did get multiple branches syncing using git-p4 once, using the --detect-branches option. However I don't use it much and I didn't take great notes when I was doing the configuration.
Here's what I do recall. If anyone can flesh out these steps, that would be very helpful.
Perforce branch structure
I experimented with a simple branch structure from the Perforce sample depot, with a main branch and two release branches.
//depot/Jam/MAIN //depot/Jam/REL2.1 //depot/Jam/REL2.2
Perforce branch specs
I then created a branch spec for each release branch, using the same name as the branch folder. (I don't think that's strictly necessary.)
p4 branch REL2.1 -> View: //depot/Jam/MAIN/... //depot/Jam/REL2.1/... p4 branch REL2.2 -> View: //depot/Jam/MAIN/... //depot/Jam/REL2.2/...
I made a workspace that maps in all of my Jam branches.
p4 client bruno_ws_jam -> View: //depot/Jam/... //bruno_ws_jam/depot/Jam/...
I made a new directory for git-p4 to use, and copied in the p4config file from my Perforce workspace to provide the right Perforce connection settings. Then I set up a git repo and initialized git-p4.
> git init . > git p4 sync //depot/Jam@all --detect-branches
Now I can see the three Jam branches in git:
> git branch -r p4/Jam/MAIN p4/Jam/REL2.1 p4/Jam/REL2.2
Now I want to map git branches to these Jam branches:
> git checkout -b master p4/Jam/MAIN > git checkout -b REL2.1 p4/Jam/REL2.1 > git checkout -b REL2.2 p4/Jam/REL2.2 > git branch REL2.1 * REL2.2 master
Now let's make an edit on two branches.
> git checkout master > vim .\src\glob.c > git commit -am "main" > git checkout REL2.1 > vim .\src\glob.c > git commit -am "rel2.1"
Now I can push these changes upstream. I just need to run the sequence of commands on each git branch, and the changes will go the appropriate upstream Perforce branch.
> git checkout REL2.1 > git p4 rebase > git p4 submit > git checkout master > git p4 rebase > git p4 submit
I now see those two changes replayed into the appropriate branches in Perforce.
> p4 changes -m2 //depot/Jam/... Change 12154 on 2012/02/06 by bruno@bruno_ws_jam 'main ' Change 12153 on 2012/02/06 by bruno@bruno_ws_jam 'rel2.1 ' > p4 describe -s 12154 Change 12154 by bruno@bruno_ws_jam on 2012/02/06 09:47:17 main Affected files ... ... //depot/Jam/MAIN/src/glob.c#6 edit > p4 describe -s 12153 Change 12153 by bruno@bruno_ws_jam on 2012/02/06 09:47:02 rel2.1 Affected files ... ... //depot/Jam/REL2.1/src/glob.c#2 edit