I’m cloning a repo that was first generated by git-p4. git-p4 uses a ‘remotes/p4/master’ branch that I would like to track. How do I tell git, which is cloning that repo, to track remotes/p4/master as well? That way I would be able to check out “origin/remotes/p4/master” or something.
I’m cloning a repo that was first generated by git-p4. git-p4 uses a ‘remotes/p4/master’
Share
You can adjust the fetching properties to mirror those references as well, although not as part of a standard clone.
So a sequence like:
This will fetch
refs/remotes/p4/release/1.1for example ininfo-service.gitto berefs/remotes/origin/p4/release/1.1in your clone, and you could create a branch based on it withgit checkout -b r1.1-fixes origin/p4/release/1.1Having said all that, in my Perforce replica repos, I create actual branches to mirror all the p4 remote branches, largely to avoid having to go through all the above. It also gives me a chance to fix up the naming from p4 path prefixes to git branch names (so
p4/mainbecomesmaster,p4/release/1.1becomesr1.1etc). I use my own p4-to-git replication, but you could do much the same by looping over the p4 remote refs withgit for-each-refand setting local branches usinggit update-ref.