Wanted to merge code from one repository to another repository

Viewed 67

I have two forked git repositories, let's say repo1- git@github.com:vikasgope/project1.git repo2- git@github.com:vikasgope/project2.git repo2 is created from repo1 some months ago. Now me and some other developers worked on repo2 and modified some files into it, meanwhile some others developers also worked on repo1 and they have also modified some files into it.

Now I want that repo2 should have all changes done in repo1 as well as repo2. How can we merge the changes available in repo1 into repo2 with changes done in both repos (repo1 and repo2). And I have to preform this process time to time as have to take latest code from repo1 and put that into repo2.

FYI - Currently what I tried is

  1. git clone git@github.com:vikasgope/project1.git
  2. git remote add upstream git@github.com:<upstream_user>/project1.git
  3. git remote add project2 git@github.com:<upstream_user>/project2.git
  4. git fetch upstream
  5. git fetch project2
  6. git pull project2 master

But the problem with this is there are lot of files showing as conflicts Those files that are changed in repo1 only and not changed in repo2, also showing as conflicts.

Could anyone please help me out to do a efficient way, to merge all the change in repo1 to repo2 with all changes that done in repo2.

1 Answers

Those files that are changed in repo1 only and not changed in repo2, also showing as conflicts.

There should not show any conflict.
Which means you need to check what kind of concurrent modification they are showing.

Typical source for conflicts when merging files from two different projects/teams are:

  • different code reformatting options (tab vs. space, for instance)
  • different EOL (end-of-line, newline character/line feed sequence: \n vs. \r\n)
Related