forked from Fraser999/Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_clone.sh
More file actions
68 lines (59 loc) · 2.5 KB
/
git_clone.sh
File metadata and controls
68 lines (59 loc) · 2.5 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
read -p "Enter your GitHub username: " User
echo ""
git clone git@github.com:$User/MaidSafe MaidSafe-$User
echo "==============================================================================="
echo -e "Configuring super-project\n-------------------------"
cd MaidSafe-$User
git remote add upstream git@github.com:maidsafe/MaidSafe
git remote set-url --push upstream disable_push
git fetch upstream
# Create local tracking branches 'master' and 'next' if these exist in 'origin/', checkout to 'next'
# and merge 'upstream/next'.
CurrentWorkingBranch=$(git rev-parse --abbrev-ref HEAD)
if [ `git branch --list -r origin/master` -a $CurrentWorkingBranch != master ] ; then
git branch -t -f master origin/master
fi
if [ `git branch --list -r origin/next` -a $CurrentWorkingBranch != next ] ; then
git branch -t -f next origin/next
git checkout next
git merge upstream/next
fi
# Display info on remotes, branches and current status of 'next'.
echo ""
git remote -v
echo ""
git branch -vva
echo ""
git status
echo "==============================================================================="
echo -e "Initialising submodules\n-----------------------"
git submodule update --init
echo "==============================================================================="
for i in `grep path .gitmodules | sed 's/.*= //'` ; do
Submodule=$(git -C $i config --get remote.origin.url | sed 's#.*/##')
echo -e "Configuring $Submodule\n------------`echo "$Submodule" | tr [:print:] -`"
git -C $i remote rename origin upstream
git -C $i remote set-url --push upstream disable_push
git -C $i remote add origin `git -C $i config --get remote.upstream.url | sed 's/github.com:maidsafe/github.com:'$User'/'`
git -C $i fetch origin
# Create local tracking branches 'master' and 'next' if these exist in 'origin/', checkout to 'next'
# and merge 'upstream/next'.
CurrentWorkingBranch=$(git -C $i rev-parse --abbrev-ref HEAD)
if [ `git -C $i branch --list -r origin/master` -a $CurrentWorkingBranch != master ] ; then
git -C $i branch -t -f master origin/master
fi
if [ `git -C $i branch --list -r origin/next` -a $CurrentWorkingBranch != next ] ; then
git -C $i branch -t -f next origin/next
git -C $i checkout next
git -C $i merge upstream/next
fi
# Display info on remotes, branches and current status of 'next'.
echo ""
git -C $i remote -v
echo ""
git -C $i branch -vva
echo ""
git -C $i status
echo "==============================================================================="
done