0

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
Daniel Farrell
  • 9,316
  • 8
  • 39
  • 62
  • what is the output of `git branch -a`? – eftshift0 Feb 09 '23 at 10:49
  • ... and, are there fancy options for `git-p4` to increase verbosity? I think there are for `git-svn`, for example. – eftshift0 Feb 09 '23 at 10:51
  • Updated with branch info. Thanks for the help. Let me see if there is verbose option. – Daniel Farrell Feb 09 '23 at 10:52
  • seems like you can start playing with those branches. If your local `master` is empty and you want to set it where `p4/master` is, you can do `git reset --hard p4/master`... and also `git branch --set-upstream-to=p4/master` if you want to set it as its upstream. – eftshift0 Feb 09 '23 at 10:58
  • I might be picking up my first git-p4 points here (Have no experience there). Let me write what I provided there as an answer – eftshift0 Feb 09 '23 at 11:04
  • Yes please do. This `git reset --hard p4/master` made files appear. Would you be able to explain why that worked? – Daniel Farrell Feb 09 '23 at 11:06
  • 1
    `git reset --hard` moves your working tree, index, `HEAD` and the branch pointer (if you are using a local branch) to the commit that you point to. You were on... well, nothing, an empty branch. So by resetting **hard**, you go.... _somewhere_. – eftshift0 Feb 09 '23 at 11:10

1 Answers1

1

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.

eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • Interestingly `$ git branch --set-upstream-to=p4/master` gives and error `fatal: cannot set up tracking information; starting point 'p4/master' is not a branch`. But I think I need to interact with the branch using the `git p4` command so maybe that is why? – Daniel Farrell Feb 09 '23 at 11:14
  • 1
    that is _very_ interesting. But I don't know how you should deal with it given that it's `git-p4` stuff. – eftshift0 Feb 09 '23 at 11:15