Skip to content

Instantly share code, notes, and snippets.

@detunized
Created December 26, 2017 15:06
Show Gist options
  • Save detunized/2fe8f46d6a7b2c696010bc617f76bf8f to your computer and use it in GitHub Desktop.
Save detunized/2fe8f46d6a7b2c696010bc617f76bf8f to your computer and use it in GitHub Desktop.
Join a bunch of repos into subfolders and rewrite the history to reflect where the commits are coming from
#!/bin/bash
set -e
# Clone repos locally into original/
(
mkdir original
cd original
git clone git@bitbucket.org:detunized/lastpass-sharp.git
git clone git@bitbucket.org:detunized/1password-sharp.git
git clone git@bitbucket.org:detunized/truekey-sharp.git
git clone git@bitbucket.org:detunized/dashlane-sharp.git
git clone git@bitbucket.org:detunized/roboform-sharp.git
git clone git@bitbucket.org:detunized/stickypassword-sharp.git
git clone git@bitbucket.org:detunized/zoho-vault-sharp.git
)
# LastPass repo has committer messed up in some commits
(
cd original/lastpass-sharp
# Fix up the committer/author
git filter-branch -f --env-filter '
export GIT_COMMITTER_NAME="Dmitry Yakimenko"
export GIT_COMMITTER_EMAIL="detunized@gmail.com"
export GIT_AUTHOR_NAME="Dmitry Yakimenko"
export GIT_AUTHOR_EMAIL="detunized@gmail.com"
' -- --all
)
# Join all the repos
(
cat >list-of-repos <<EOT
lastpass original/lastpass-sharp
dashlane original/dashlane-sharp
zohovault original/zoho-vault-sharp
stickypassword original/stickypassword-sharp
truekey original/truekey-sharp
1password original/1password-sharp
roboform original/roboform-sharp
EOT
# Join
curl -s https://raw.githubusercontent.com/Oakleon/git-join-repos/master/git-join-repos \
| bash /dev/stdin list-of-repos
rm list-of-repos
git gc --aggressive
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment