ebbishop
ebbishop

Reputation: 1983

Combine add git repository one repo as branches

I have two directories, each their own git repo, that I have realized are two parts/versions of the same project. I'd like to add them as sub-directories to a new project folder, while preserving the commit history of each.

Ideally, project_A and project_B would be branches of the same parent git repository.

Existing file structure:

project_A
| --.git
| --project_B files

project_B
| --.git
| --project_B files

Taraget File Structure:

ParentProjectFolder
|--project_A
|   | --project_A files
|--project_B
|   | --project_B files

Can this be done?

Upvotes: 0

Views: 34

Answers (2)

Fujiao Liu
Fujiao Liu

Reputation: 2253

for you situation, try to use git submodules

in your ParentProjectFolder,

git submodule add  your_remote_repo_url

check the doc http://git-scm.com/book/en/v2/Git-Tools-Submodules

Upvotes: 0

Madara's Ghost
Madara's Ghost

Reputation: 175017

  1. Create a branch on target repo
  2. Add source repo as a remote of the target repo (Lookup git remote, you can add local repositories as well)
  3. Link the source branch and the target branch with git branch -u
  4. git pull into the target branch.

You may have to resolve conflicts and perform a merge, depending on what changes there are on either repository.

Upvotes: 1

Related Questions