Created
January 21, 2022 08:18
-
-
Save berkus/b4c6097bb95ea51069a449013c86b5a0 to your computer and use it in GitHub Desktop.
Pijularize a Git repository with all branches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
set -x | |
reponame=`basename $(pwd)` | |
echo "#######################################################################################" | |
echo "# Script to import all local branches from current repository (${reponame}) into pijul" | |
echo "# Will create a bunch of temp repos for import, so have sufficient disk space" | |
echo "#######################################################################################" | |
all_branches=(`git branch -a | grep -v remotes/ | tr '*' ' ' | awk '{print $1}' | tr '\n' ' '`) | |
echo "*** Importing ${#all_branches[@]} local branches to pijul" | |
mkdir -p ../${reponame}-temp | |
rm -rf ../${reponame}-pijul | |
pijul init ../${reponame}-pijul | |
for channel in "${all_branches[@]}" | |
do | |
echo "####################################################################################" | |
echo "*** Importing ${channel}" | |
echo "####################################################################################" | |
rm -rf ../${reponame}-temp/${channel} | |
mkdir -p ../${reponame}-temp/${channel} | |
cp -r . ../${reponame}-temp/${channel} | |
(cd ../${reponame}-temp/${channel}; \ | |
git reset --hard ${channel}; \ | |
git clean -fdx; \ | |
pijul git; \ | |
pijul fork ${channel}) | |
(cd ../${reponame}-pijul; \ | |
pijul channel new ${channel}; \ | |
env EDITOR=true pijul pull --from-channel ${channel} --to-channel ${channel} ../${reponame}-temp/${channel}) | |
rm -rf ../${reponame}-temp/${channel} | |
done | |
rm -rf ../${reponame}-temp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run from inside a git repo.
Copies only local branches, checkout remote branches locally if you need to migrate them.
Temporary hack until pijul is taught to import branches by itself.