1

Perforce have a concept of branch mapping where you just define a mapping between different paths.

You could have the following saved branch mapping

//depot/proj1/path1/... //depot/proj1/path1-renamed/...

After this mapping is done the development can continue in both branches and from time to time a merge based on the mapping can happen.

In git I have a similar "renaming" and independent branch development after that but still I want to merge from time to time the changes from one branch into the other.

#desired in git
//https://github.com/mucommander/mucommander-commons-io/tree/master/src/main/java/com/mucommander/commons/io //https://github.com/mucommander/mucommander-commons-io/tree/master/src/main/java/com/mucommander/commons/io2

How should I do it? What is the perforce branch mapping equivalent in git?

raisercostin
  • 8,777
  • 5
  • 67
  • 76
  • 1
    There is no equivalent behavior in Git. You would probably want a symlink. – user229044 Sep 23 '15 at 13:08
  • I didn't expect this. I'm working on a solution using rename before and after integrating to the master. Basically I'm creating the mapping as a suite of `git mv ` – raisercostin Sep 24 '15 at 11:24
  • I do understand what you're trying to do, and again, all I can tell you is that I do not believe Git supports this. You should symlink path2 to path1 and make your changes. – user229044 Sep 24 '15 at 12:45
  • The problem with symlinking is that I cannot share the history from one branch to the other. By merging after renaming i get the history plus some unwanted details about renaming back and forth. If and when I have a working solution I will describe it as an answer. Thanks @meagar – raisercostin Sep 24 '15 at 13:11
  • 1
    if you just want to have path1 and path1-rename just make a branch and rename the directory (git mv in the new branch). – mhstnsc Sep 27 '15 at 19:01
  • This might be also useful - http://stackoverflow.com/questions/4722423/how-to-merge-two-branches-with-different-directory-hierarchies-in-git . But remains to be seen – raisercostin Sep 28 '15 at 20:57

2 Answers2

0

I think in Git you would create another branch instead. So you'd have two branches, io and io2, rather than two directories under a single branch.

To keep the relationship between the two, you'd create io2 from io by using git branch--track kid parent.

sferencik
  • 3,144
  • 1
  • 24
  • 36
0

If path1 and path1-renamed are supposed to be actual paths, then the fact that they have the same contents should be reflected with a single symlink or multiple symlinks for the shared files (if small differences can exist).

There is no sense of 'merging' directories at the level of git. You just 'sync' them in whatever way (e.g. copying, symlinking, etc) and commit the result.

aronisstav
  • 7,755
  • 5
  • 23
  • 48
  • 1
    I would like to `merge` them since I modified `path1/A.java` while someone else modified `path2/A.java`. I would like to merge the changes made in the other branch knowing that at some moment they renamed path1 to path2 and that A.java is actually the same unit of work for both of us. – raisercostin Sep 23 '15 at 15:10
  • Offering alternatives here, since exactly what you seem to want is not possible in git: If they simply renamed (and no original copy was kept) then you could rebase them on top of your branch, ending up with your changes then theirs and a rename somewhere in between and then rename back to restore order. – aronisstav Sep 23 '15 at 19:57