forked from cloudflare/templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge.sh
executable file
·32 lines (26 loc) · 873 Bytes
/
merge.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash -xe
# @see https://stackoverflow.com/a/66632451/3577474
#
# To merge repositories into the current.
# To see the log of the new repo use 'git log --follow -- unprefixed-filename'
# So if the file is repo/test.cpp use 'git log --follow -- test.cpp'
#
# `git branch -a` will show newly created branches.
rm -rf clones
mkdir -p clones
repo="$1" # url of the remote repo
rn="$2" # new name of the repo, you can keep the same name as well.
git clone ${repo} clones/wip
cd clones/wip
git checkout -b migrate
git filter-repo --to-subdirectory-filter ${rn} --force
cd ../..
git remote add ${rn} clones/wip
git fetch ${rn}
git rebase --rebase-merges --onto dev --root ${rn}/migrate --committer-date-is-author-date --merge -s recursive -X theirs
git checkout -b ${rn}
git checkout dev
git merge ${rn}
git branch -d ${rn}
git remote remove ${rn}
rm -rf clones/wip