Merge two git repositories of same project Merge two git repositories of same project git git

Merge two git repositories of same project


Sure, using the ours strategy!

Follow the the next steps (lines starting with # are comments):

# Navigate to your updated projectcd your-updated-project# Add a remote pointing to the other git repository # (it can be a local path or an url; I used a local path)git remote add old-project ../path/to/the/old/git/repo# Get the content from that repogit fetch old-project# Merge the the old repo master branch in your current branch,# BUT keeping your recent changes (see -s ours)git merge old-project master -s ours

If you want to merge another branch from the old git repo, do git merge old-project <branch-name> -s ours (replace <branch-name> with the branch name you want to merge).


You may try to add old repository as remote repository at your new repository then pull changes to merge, assuming your repositories will be the baseline.

$> git remote add old /path/to/other/gitrepo/.git# if you want to merge their master branch then pull from it#   otherwise specify the correct branch to merge$> git pull old master