Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

migrating from perforce to git

I have perforce repo //depot/myprog/... which is having branches as

  1. //depot/myprog_branches/version1/myprg/...
  2. //depot/myprog_branches/version2/myprg/...

Now i want to stop using perforce and want to migrate my whole code with branch and tag histroy to git .

How to do it ? I know i can use git p4 command,but it is taking two much time and we have only 12 hours of perforce login session, the command is failing as it is auto logging out .

Any help would be greatly appreciated .

like image 292
Niraj Avatar asked May 09 '26 15:05

Niraj


1 Answers

It's a bit nasty, but you can just setup a cron that logs you in every hour or so. You obviously have to put your password into the cron script, which is why it's nasty.

The other way is to clone your repo using normal Perforce commands at the revision you want to start from, and then trick git-p4 into using it.

i.e. something like:

$ p4 client
<create suitable client spec>
$ p4 sync //depot/foo
$ cd foo
$ git init
$ git add .
$ git commit

Your git commit needs to be in the right format, i.e. a message, followed by:

[git-p4: depot-paths = "//depot/foo": change = 1234]

Then do:

$ mkdir .git/refs/remotes/p4
$ git rev-parse HEAD >.git/refs/remotes/p4/master

Now git-p4 will use your repo:

$ git p4 sync
like image 184
Luke Avatar answered May 12 '26 09:05

Luke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!