Skip to content

Instantly share code, notes, and snippets.



Last active May 2, 2020
What would you like to do?
Join repos into subfolders with flat history
set -euo pipefail
repos="1password bitwarden dashlane lastpass opvault passwordbox roboform stickypassword truekey zoho-vault"
# pull all repos
for repo in $repos; do
echo $repo
cd $REPO_DIR/$repo
git pull -v --ff
# merge
rm -rf joined
mkdir joined
cd joined
git init .
for repo in $repos; do
git remote add $repo ~/devel/$repo-sharp
git fetch $repo
git checkout -b $repo $repo/master
echo -n "$repo: " > prefix
git filter-branch \
-f \
--tree-filter "mkdir -p .original/$repo && rsync -a --remove-source-files ./ .original/$repo/" \
--msg-filter "cat $(pwd)/prefix -" \
rm prefix
# create master
git checkout --orphan master
git rm -rf .
# cherry pick into the master
for i in $(git log --pretty='%H' --author-date-order --reverse $repos); do
GIT_COMMITTER_DATE=$(git log -1 --pretty='%at' $i) \
git cherry-pick $i
# cleanup
for repo in $repos; do
git branch -D $repo
git remote remove $repo
git update-ref -d refs/original/refs/heads/$repo
git gc --aggressive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.