I have a dotfiles repository. I want to merge another one with submodules (prezto) into it, so I can conveniently have everything in one repository without the inconvenience of submodules.
How can I subtree merge prezto into my dotfiles repository with all its submodules?
I can use submodules, I can split and merge subtrees either the "old fashioned" way or with the newer git subtree tool.
I just don't know how to do this specific case.
Alexander Mikhailian created a script to convert all the submodules in subtrees, you should be able to adapt it to your case.
Presenting here the steps:
cat .gitmodules |while read i
do
if [[ $i == \[submodule* ]]; then
mpath=$(echo $i | cut -d\" -f2)
read i; read i;
murl=$(echo $i|cut -d\ -f3)
mcommit=`eval "git submodule status ${mpath} |cut -d\ -f2"`
mname=$(basename $mpath)
echo -e "$name\t$mpath\t$murl\t$mcommit"
git submodule deinit $mpath
git rm -r --cached $mpath
rm -rf $mpath
git remote add $mname $murl
git fetch $mname
git branch _$mname $mcommit
git read-tree --prefix=$mpath/ -u _$mname
fi
done
git rm .gitmodules
I think the easiest route for you would be to apply the script on the prezto
repo and then make the repo a subtree in the dotfiles
repository.
After executing the script in the prezto
repository you will use the following steps to create the subtree:
Add a new remote URL pointing to the prezto
repo into the dotfiles
.
git remote add -f prezto [email protected]:path/prezto.git
Merge the prezto
project into the local dotfiles
project. This doesn't change any of your files locally, but it does prepare Git for the next step.
git merge -s ours --no-commit prezto/master
Create a new directory called prezto-subdir
(or whatever you like), and copy the Git history of the prezto
project into it.
git read-tree --prefix=prezto-subdir/ -u prezto/master
Commit the changes to keep them safe.
git commit -m "Subtree merged in prezto"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With