-
Notifications
You must be signed in to change notification settings - Fork 0
/
migit.sh
executable file
·51 lines (45 loc) · 1015 Bytes
/
migit.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
usage() {
echo "Welcome from Migit."
echo "Before starting you must have access to git server for read and write !"
echo "Usage:"
echo " If your repo is on git server:"
echo " ./migit.sh {Actual git repository URL} {New git repository URL}"
echo " If your repo is on your computer:"
echo " ./migit.sh {Repository path} {New git repository URL}"
}
localRepo() {
echo "Local repository mode."
cd $2
git fetch --tags
git remote rm origin
git remote add origin $2
git push origin --all
git push --tags
}
remoteRepo() {
echo "Remote repository mode."
FOLDER="/tmp/"$$
git clone --mirror $1 $FOLDER
cd $FOLDER
git fetch --tags
git remote rm origin
git remote add origin $2
git push origin --all
git push --tags
# cd -
rm -rf $FOLDER
}
if [[ "$#" != "2" ]]
then
usage
exit 1
fi
if [[ $1 == *"@"* ]]
then
remoteRepo
exit 0
else
localRepo
exit 0
fi