Migrating codebase from p4 to git - looking for a step by step guide

301 Views Asked by At

I'm trying to migrate a perforce repository to git. I'm following this link and also I have gone through numerous stackoverflow questions. Finally now I'm able to migrate p4 code to git. However, I want to achieve 1 more thing post the migration.

Migration steps that I followed:

git p4 clone //depot/development/<path>/main/@all

git remote add origin [email protected]:<org>/demo.git

git branch -M main

git push -u origin main

Above steps work fine for 1 time migration.

Lets say there is a new commit in the perforce and I want to sync it to the git? How do I do it?

Steps I tried.

1. git p4 sync (works)

2. git rebase

3. git push -u origin main

No errors. However, I don't see the new p4 commit on the git. I'm sure I'm missing something here. Can anyone point me in the correct direction? I want to preserve the timestamp, author and ofcourse the changes in the commit when its sync'd to git. Also, I'm quite new to Git. A 1 liner on any command on what it does(if there are any command that I need to execute) really would help me understand it better. If you need any more details I'm happy to provide.

Thanks in advance.

1

There are 1 best solutions below

0
Douglas Leeder On

I've tried it with a test server.

If you do git log remotes/p4/master you'll probably see the new commits, but git-p4 sync doesn't put them into a local branch.

If instead of:

git p4 sync
git rebase

You do:

git p4 rebase

You should get the new commits on your local branch.

You might want to do the original clone with --branch=main so that the perforce branch name is //remotes/p4/main rather than //remotes/p4/master