Skip to content

Instantly share code, notes, and snippets.

Last active November 26, 2021 08:41
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
Copy link

Schoaf commented Apr 23, 2021

Why did you change line 25. I wanted to correct it but then I saw that you purposely changed that line. It just cannot work this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment