Search code examples
gitgit-p4

git-p4 clone is mandatory to run git-p4 sync?


I am using git-p4 sync command to get the files from perforce to git repository.

I have been working in git for testing few changes on forked git repository (from original repository). I have buildbot CI build step configured to run git-p4 sync command :-

/home/test-worker/staging-worker/venv3/bin/python3 /usr/local/bin/git-p4 sync --use-client-spec --keep-path --branch refs/heads/sv4/main

I get the issue :-

No remote p4 branches. Perhaps you never did "git p4 clone" in here.

But in original repository, Same build step is working fine where they have not ran any git-p4 clone as pre-requisite.

One difference i notice the entry p4/HEAD -> test/main in original repo with build command :- git branch -r And this entry is created just after running above (git-p4 sync) command. I don't understand why the same entry is not creating in my forked test repository. Please advice.

I try to run git-p4 clone on forked test repo (root folder of repo)

/home/test-worker/staging-worker/venv3/bin/python3 /usr/local/bin/git-p4 clone --use-client-spec --keep-path --verbose --branch refs/heads/test/main //sw/pvt/hello

But it creates new directory named 'hello' inside root folder of forked repo and i could see p4/HEAD -> test/main inside the 'test' folder. Basically i don't want to create any new folder. Instead i want to update the forked repo where i have the branch test/main.

Please advice.


Solution

  • You should not have to call python3 directly. Please add the following alias to etc/gitconfig:

    [alias]
    p4=!python.exe <path to git-p4.py>
    

    git p4 clone creates the git repo for the repo in perforce. It should only be used once. After that git p4 sync should be used.

    I don't use --use-client-spec. I work directly with the depot so that all files are sync'd

    e.g. git p4 clone --detect-branches "//depot/project1@all"

    git p4 sync --detect-branches "//depot/project1@all"