tags:

views:

410

answers:

1

Is there a tool that allows me to gain the same functionality as git-svn for Perforce? I saw git-p4 on github but it looks like this imports source from a git repo to a Perforce repo. Does it go the other way around? Is it intended to be used as a frequent tool or just a 1 time, import-only type of tool?

Scenario: I am a contractor, my client uses Perforce for their source control, but I would like to use git locally.

+4  A: 

git-p4 can go both ways. Use git-p4 sync or git-p4 rebase to update your local workarea, then use git locally. When ready to submit your git commits into p4, use git-p4 submit.

You will need to create a P4 client (in a separate place from your git workarea) and use it exclusively for synchronizing using git-p4.

I use this locally and it has been working well for months, with a few caveats:

  • You can use git branches locally but P4 will not know anything about them. It will see only master.

  • File renames will show up in P4 as add+delete instead of the preferred integrate+delete.

  • Git commits are recreated when running git-p4 submit, so the timestamp will be off, and you may have merge issues with your other git branches. (Just like the "recover from upstream rebase" problem.)

ScottJ
Thanks Scott, this is great news. I'll give this a shot soon. When you run git-p4 submit, how does it know which p4 branch/location to submit to? I'd like to see how to deal with different p4 branches :)
Michael Brennan
It submits the files using the p4 client you tell it to. So wherever that client is mapped. I suppose you could change the mapping of that p4 client at any time, but you'd have to be careful because git-p4 uses `p4 changes ...` to find which changes need to be imported into git, so when you change the client mapping, git-p4 might not get all the changes it needs to sync your git workarea.
ScottJ
Added another caveat about how `git-p4 submit` basically rebases your git workarea.
ScottJ
git-p4 submit rebases your working directory? What does it use as the base?
Michael Brennan
Also, a few more things:1. You said you have to create a p4 client in a seperate place from your git working area. So to be clear, you don't git init in your p4 workspace? If not where do you keep your git workspace and how do you sync between the git workspace and the p4 workspace?2. Where is the latest p4-sync script that you use? The latest one I've seen is http://github.com/sannies/git-p4
Michael Brennan
The rebase comes from the p4root. It imports all the changes that it just submitted to p4. The commits are the same as the ones already in git except the change description now includes the p4 change number. And that causes the git hash to change.
ScottJ
Correct, you do not git init in your p4 workspace. You can put the git workspace anywhere else but there. Use `git-p4 sync` or `git-p4 rebase` to bring in the latest changes from p4 into git.I don't know about the "latest" git-p4, but I use the one in the official git distribution, under contrib/fast-import (or something like that).
ScottJ
I can't get the script to work on Windoze; but I've heard it's actually part of the git contrib project. Any clue how to get it to run on Windows?
Michael Brennan