0

I have two Git repositories:

  1. /api/pom.xml
    /jpa/pom.xml
    
  2. /mailbox/api/pom.xml
    /mailbox/jpa/pom.xml
    /protocols/api/pom.xml
    

The second repository have a mailbox folder that has the exact same structure that the first Git repository. Due to workflow changes, I now need to work on the second repository, and need to transfer my working branches to the new repository.

I created a patch in the first one (let say on file api/pom.xml) and try to apply it in the second one, under the /mailbox path. So I have only one problem: git am refuses to do the work, pretending that:

<file> does not exist in index

I tried directory option and -p1 option. Note: patch -p1 does the job, but I have ~80 patch to apply in all my branches:

patch + git add + git commit

Is there any cheaper way to do it?

Steven Penny
  • 82,115
  • 47
  • 308
  • 348
Benwa
  • 91
  • 4

1 Answers1

0

The easiest way would be to consider mailbox in your second repo as being the first one, declared as a submodule:

cd /path/to/second/repo
git submodule add -- /url/first/repo mailbox

That way, once you have done some changes in mailbox folder, you add and push (to the first repo from the mailbox submodule folder), then cd .. to the main parent repo, add and push (recording the gitlink, special entry in the index).

No more patch needed.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • Thanks for the answer ! I thought to it. But code comes from SVN => git replication and I need to do that in an existing repository... The funny part is that the first repository is a submodule :-p – Benwa Oct 09 '15 at 08:39
  • @Benwa that should prevent you to add that git repo as a submodule, while doing from that git repo some git svn command. – VonC Oct 09 '15 at 08:57