ClementNerma
ClementNerma

Reputation: 1109

Combine two git folders

I've currently a git repository that I uploaded to GitHub. When I was to my school, I wanted to develop the code and downlad the repository (without the ".git" folder, so I just got the code itself).

I did many changes and committed multiple times, but now I'm home I want to merge the new commits I made on the new folder on the old one.

Here is an example :

Original folder

Initial commit [with no code]
Commit 1
Commit 2

New folder

New initial commit (with the code of commit 2)
Commit 3
Commit 4
Commit 5

Now I want to add Commit 3, Commit 4 and Commit 5 to the original folder. How can I do it ?

Upvotes: 1

Views: 388

Answers (1)

VonC
VonC

Reputation: 1328712

You can fetch one repo in the other, and then if you want merge them

A merge would only be possible since git 2.9 if the branches has no common history

git merge --allow-unrelated-histories a b

In your case, you could directly pull from the second repo:

git remote add second_repo /path/to/second/repo
git pull second_repo master

That will be enough to get the commits from the second repo back into the first one.

Upvotes: 1

Related Questions