Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

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
Comment

how to merge two repositories in github

git merge master-holder --allow-unrelated-histories
Comment

can i merge two repositories 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
Comment

PREVIOUS NEXT
Code Example
Shell :: get name of files in directory 
Shell :: git stash specific files 
Shell :: unstage particular file git 
Shell :: find next greater number with same digits 
Shell :: list ios devices command line 
Shell :: download project from github 
Shell :: install docker on ubuntu 
Shell :: customize ubuntu terminal in windows 
Shell :: install zabbix 
Shell :: Switching the namespaces using kubectl commands 
Shell :: add one drive to ubuntu 
Shell :: xubuntu desktop 
Shell :: how to search in git bash 
Shell :: cp -r copy linux directory or file 
Shell :: install sketchjs 
Shell :: imapgrab nodename nor servname provided, or not known 
Shell :: bash mail subject variable 
Shell :: how to edit file in termux 
Php :: tinker color auto 
Php :: php remove last character in string 
Php :: laravel Str::random 
Php :: how to get ip address of client using php 
Php :: php get current domain 
Php :: Call to undefined method JeroenNotenLaravelAdminLteHelpersMenuItemHelper::isSearchBar( 
Php :: autoprefixer: Replace color-adjust to print-color-adjust. The color-adjust shorthand is currently deprecated. laravel 
Php :: php remove extension from url 
Php :: laravel random query 
Php :: your requirements could not be resolved to an installable set of packages. composer 
Php :: prepend 0 to number php 
Php :: php make query string from array 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =