9

I have browsed through the web, but I cannot find an answer. What I am trying to do is the following:

  1. I have a git repository which has been used for over 1 year with lots of commits
  2. Due to productization, the code has to be moved into a P4 rep.
  3. However, the codebase (after transport) may change in git as well as P4

Now lets assume that reference branch in git is master

What I did is the following:

  1. Copy the latest code from git into P4 and submit it there
  2. Use git-p4 sync --branch=refs/remotes/p4/masterp4 //../ in order to create a new branch in my existing repository
  3. git merge master into masterp4
  4. does not work since a common commit is missing
  5. git-p4 submit, moreover, is not able to work with merge commits anyway

Another option was rebasing

  1. Start with an empty repository in P4
  2. Use git-p4 sync to create an empty masterp4 branch in git
  3. Rebase master onto masterp4
  4. Rebase masterp4 onto remote/p4/master
  5. Leads to thousands of p4 changelists.

The main problem is the broken link between the master branch and this masterp4 branch. I wondered if there is not an easier solution anyway. Unfortunately, I am a git n00b.

Thanks for any ideas,

Philipp

Noel Yap
  • 18,822
  • 21
  • 92
  • 144
Philipp Herzig
  • 350
  • 6
  • 10
  • 2
    Perforce just came out with Perforce Git Fusion. http://www.perforce.com/git-fusion – Daniel A. White Nov 07 '12 at 13:02
  • thx Daniel, I am aware of that but some colleagues told me that it hasn't worked well in their environment either. However, they didn't try git-p4. Otherwise I really believe that there is a solution for that. – Philipp Herzig Nov 07 '12 at 13:13
  • Can you do the merge with --no-ff to create a single commit? – Douglas Leeder Nov 07 '12 at 19:24
  • This blog might provide some food for thought: http://www.perforce.com/blog/121030/git-fusion-working-open-source. It uses a staging repository as a way to reconcile the data, since both Git Fusion and git-p4 have some limitations. (Git Fusion will support merge commits early next year.) – randy-wandisco Nov 08 '12 at 01:37
  • Maybe --squash on the git merge command might help? That should create a single commit with the same effect as merging the branch. (Loses history though). – Douglas Leeder Nov 08 '12 at 09:55
  • I guess an additional question might be why you don't want 1000s of perforce commits - that way you preserve your history of the project? – Douglas Leeder Nov 08 '12 at 09:56

1 Answers1

2

I'd go with creating 1000s of Perforce commits, so that history is preserved.

Douglas Leeder
  • 52,368
  • 9
  • 94
  • 137