-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSubmodule.sh
More file actions
34 lines (22 loc) · 704 Bytes
/
Submodule.sh
File metadata and controls
34 lines (22 loc) · 704 Bytes
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
33
34
path=$1
url=$2
echo Warning! This script is dangerous and may mess things up! Comment out the '"exit"' in the script if you really want to continue.
exit
# split the "main repo"
git subtree split -P $1 -b NewBranch$1
# Create your repository, and get git url
# add remote for branch
git remote add submodule $2
# push the submodule
git push -u submodule NewBranch$1:master
# remove path
git rm -r $1
# Stage and commit changes
git add -A $1
git commit -m "Remove $1 for submodule replacement"
# add the submodule
git submodule add -b master $2 $1
# and once your submodule is added commit the .gitmodules file
git add .gitmodules
git commit -m "Added $1 as submodule"
git remote rm submodule