gitperforcegit-p4

git p4 sync into existing git repo seems not to work


Following the docs for adding a Perforce repo into an existing git repo seems not to work

git p4 sync

If I do this I get the following

$ git p4 sync //depot/group/project/example
Doing initial import of //depot/group/project/example from revision #head into refs/remotes/p4/master

$ git log
fatal: your current branch 'master' does not have any commits yet

I think the import might be failing silently - any ideas?

Doing,

$ git branch -a
  remotes/p4/HEAD -> p4/master
  remotes/p4/master

Update with logging information using (calling again in a fresh repo.)

git init
git p4 sync --verbose //depot/group/project/example
Doing initial import of //depot/group/project/example from revision #head into refs/remotes/p4/master
commit into refs/remotes/p4/master
...
b'//depot/group/project/example/config/example.json'
...
Reading pipe: git --git-dir C:\Users\<...>\git\deleteme5\.git rev-parse --git-dir
Reading pipe: git --git-dir C:\Users\<...>\git\deleteme5\.git rev-parse --git-dir
Reading pipe: git config --bool git-p4.useclientspec
Reading pipe: git config git-p4.user
Reading pipe: git config git-p4.password
Reading pipe: git config git-p4.port
Reading pipe: git config git-p4.host
Reading pipe: git config git-p4.client
Reading pipe: git config --int git-p4.retries
Reading pipe: git config --int git-p4.retries
Opening pipe: p4 -r 3 -G login -s
Opening pipe: p4 -r 3 -G login -s
Opening pipe: p4 -r 3 -G files //depot/group/project/example/...#head
Opening pipe: p4 -r 3 -G describe -s 4021238
Reading pipe: git config git-p4.metadataDecodingStrategy
Reading pipe: git config git-p4.metadataFallbackEncoding
Reading pipe: git config git-p4.pathEncoding
Reading pipe: git config --bool core.ignorecase
Reading pipe: git config --bool git-p4.keepEmptyCommits
Opening pipe: p4 -r 3 -G users
Reading pipe: git config --get-all git-p4.mapUser
Opening pipe: p4 -r 3 -G -x - print
Reading pipe: git config --bool git-p4.importLabels
executing git symbolic-ref refs/remotes/p4/HEAD refs/remotes/p4/master

Solution

  • It looks like git-p4 has done its part in picking up the branches (well, single master branch) from p4. There is this remote branch:

      remotes/p4/master
    

    What is apparent from your situation is that git-p4 doesn't move you from where you were before doing the p4 operation.... given that you have no work done (no local branch is visible), you could set up your local master branch on top of p4/master with

    git reset --hard p4/master
    

    Careful, git reset --hard will get rid of any uncommitted files you have laying around (and also stuff in index).

    Then, if you would like to set it up as your upstream branch, you can run

    git branch --set-upstream-to=p4/master
    

    By the way, I have no git-p4 experience, so those are plain git tips, nothing special about p4 but I might be missing something, as usual.