3

I want to merge a remote repo in a subdirectory of my project. I copied manually this remote project as subdirectory in my project some days ago and I modified it. Now there is a new version of it and I want to merge the new changes in my subdirectory without losing my modifications.

Structure:

myProject
    /mySubproject1
    /mySubproject2  <-- This one is the modified remote repo (from Github)

I already tried what is the following links, but without success:

This is what I have done:

cd myProject    
git remote add -mySubproject2_github https://github.com/something.git
git merge -s ours --no-commit mySubproject2_github/master
git read-tree --prefix=mySubproject2 -u mySubproject2_github/master

But I get the following

error: Entry 'mySubproject2/.something.yml' overlaps with 'mySubproject2/.something.yml'. Cannot bind.

Is it possible what I want? Any idea how to solve it?

Community
  • 1
  • 1
Iker Aguayo
  • 3,980
  • 4
  • 37
  • 49
  • 3
    If you want to include this project inside your project *and* you want to keep it up-to-date, you may want to read up on "git submodules". – larsks Jul 10 '15 at 13:42
  • @larsks Am I able to modify the project and when I update the project, can I maintain the modifications? – Iker Aguayo Jul 10 '15 at 13:48
  • @iker you can maintain a fork that pulls from upstream and maintains your changes. So you'd ideally need a separate repo. – rubenvb Jul 10 '15 at 14:26
  • A submodule is just a git repository...so, sure. – larsks Jul 10 '15 at 14:29

1 Answers1

0

Instead of using Submodules which sometimes is a little bit messy, I used Subtrees. The subtree would be the project which I want to add to my "parent" project:

Here an example, we want to add the project nodejs-y-express from Github in our project.

Add the subtree to our project

$ git subtree add --prefix node_express_subtree https://github.com/codeheroco/nodejs-y-express-rutas master 
git fetch https://github.com/codeheroco/nodejs-y-express-rutas master

Update the project from the github

git subtree pull --prefix node_express_subtree https://github.com/codeheroco/nodejs-y-express-rutas master
Iker Aguayo
  • 3,980
  • 4
  • 37
  • 49