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 :: bash make multiple directories in current directory 
Shell :: create gitignore files 
Shell :: infinite-react-carousel install 
Shell :: angular full installation guide 
Shell :: install anaconda 
Shell :: remove gitignore files 
Shell :: bash true if grep has output 
Shell :: relaunch doc macos 
Shell :: creating a github repository from the cli 
Shell :: open tar.Z files 
Shell :: crosh 
Shell :: How can I remove the first line of a text file using bash/sed script? 
Shell :: install geopandas in jupyter notebook 
Shell :: rename local branch github 
Shell :: ubuntu run a shell script 
Shell :: bash script object array 
Shell :: github api search 
Shell :: how to compile 64 bit nasm 
Shell :: create new file terminal 
Shell :: docker delete image 
Shell :: install vuex orm 
Shell :: access from ip pgsql running in docker 
Shell :: scp file download 
Shell :: How to get current git id 
Shell :: install docker ubuntu 20 
Shell :: unzip in folder 
Shell :: batch file if statement 
Shell :: install spacemacs 
Shell :: ubuntu install latest vim 
Shell :: commit unstaged changes to new branch 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =