Created
March 30, 2020 09:34
-
-
Save t-botz/fc1485e8e07e8900caf5b55e1d63e399 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -eux | |
# Can accept arg for target dir, otherwise this script dir | |
target_dir="$( cd "${1:-$(dirname "${BASH_SOURCE[0]}")}" >/dev/null 2>&1 && pwd )" | |
pushd "$target_dir" | |
for repo in "main_repo" "repoA" "repoB" | |
do | |
mkdir $repo | |
pushd "$repo" | |
git init | |
filename="$repo.file.txt" | |
echo "$repo bla bla" > "$filename" | |
git add "$filename" | |
git commit -m "Add file $filename" | |
popd | |
done | |
pushd main_repo | |
git remote add repoA "$target_dir/repoA" | |
git remote add repoB "$target_dir/repoB" | |
git fetch --all | |
git merge -sours --allow-unrelated-histories --all --no-commit repoA/master repoB/master | |
git read-tree --prefix=modules/a -u repoA/master | |
git read-tree --prefix=modules/b -u repoB/master | |
git commit -m "Merge repoA and repoB" | |
git log -- modules/a/repoA.file.txt | |
git log --follow -- modules/a/repoA.file.txt | |
git log --full-history -- repoA.file.txt | |
popd | |
popd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full Output here: