“¿Puedo fusionar dos repositorios github?” Código de respuesta

¿Puedo fusionar dos repositorios github?

$ cp -R my-plugin my-plugin-dirty
$ cd my-plugin-dirty
$ git filter-branch -f --tree-filter "zsh -c 'setopt extended_glob && setopt glob_dots && mkdir -p plugins/my-plugin && (mv ^(.git|plugins) plugins/my-plugin || true)'" -- --all
$ cd ../main-project
$ git checkout master
$ git remote add --fetch my-plugin ../my-plugin-dirty
$ git merge my-plugin/master --allow-unrelated-histories
$ cd ..
cd ..
$ rm -rf my-plugin-dirty
Inquisitive Impala

¿Cómo se fusiona dos repositorios GIT?

# 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
Bad Bat

Respuestas similares a “¿Puedo fusionar dos repositorios github?”

Preguntas similares a “¿Puedo fusionar dos repositorios github?”

Más respuestas relacionadas con “¿Puedo fusionar dos repositorios github?” en Shell/Bash

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código