Horje
how do you merge two git repositories Code Example
how do you merge two git repositories
# The goal is to merge proj-a into proj-b
cd /path/to/proj-b

# Establish remote connection from proj-a to proj-b
git remote add old /path/to/proj-a

# Assuming both projects HEAD are pointed to master branch
# I'm using master in these examples feel free to use main if you like
# Rename the local master branch of proj-b
git checkout master
git branch -m master-holder

# Pull the the code from proj-a into proj-b
git fetch old master
git checkout --track old/master
git pull old master

# The master branch is proj-a while the master-holder is proj-b
# Now clear out all the files to have a clean merge

rm -rf *
rm .gitignore
# Only thing that should exist is the .git folder
git add .
git commit -m "Clean merge"

# Now the fun part
# Merge the master-holder branch into master
git merge master-holder --allow-unrelated-histories
# Write a comment to the commit
# I said "Merge histories"

# Make master your main branch again
git branch -m master

# Done!

# Now you should be to see the combined histories
git log

#####################
# Optional: CLEANUP #
#####################

# You no longer need master-holder branch
git branch -D master-holder

# You no longer need the remote connection since you have synced histories
git remote remove old

# Complete




Shell

Related
Modify .env File in Laravel Code Example Modify .env File in Laravel Code Example
com.android.ddmlib.InstallException: INSTALL_FAILED_VERSION_DOWNGRADE Code Example com.android.ddmlib.InstallException: INSTALL_FAILED_VERSION_DOWNGRADE Code Example
Remplace Placeholder with shell command Code Example Remplace Placeholder with shell command Code Example
mirror remote branch to local repository for fixing production issues on last deployed code Code Example mirror remote branch to local repository for fixing production issues on last deployed code Code Example
"awk -F ''" powershell Code Example "awk -F ''" powershell Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
10