/
git-functions
63 lines (54 loc) · 1.62 KB
/
git-functions
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
function git-resync-clean() {
git fetch origin && git reset --hard origin/master && git clean -f -d
}
function git-commit-push-branch() {
if [ $# -ne 2 ]
then
echo "Correct Syntax: $0 <commit message in double quotes> <branch name>."
else
git commit -a -m "$1"
git push -u origin $2
fi
}
function git-add-commit-push-branch() {
git add --all
git-commit-push-branch $1 $2
}
function git-scommit-push-branch() {
if [ $# -ne 2 ]
then
echo "Correct Syntax: $0 <commit message in double quotes> <branch name>."
else
git commit -S -a -m "$1"
git push -u origin $2
fi
}
function git-add-scommit-push-branch() {
git add --all
git-scommit-push-branch $1 $2
}
function git-rename-branch() {
git branch -m $1 $2 # Rename branch locally
git push origin :$1 # Delete the old branch
git push --set-upstream origin $2 # Push the new branch and set local branch to track the new remote
}
function git-revert-and-sync-master() {
git fetch origin && git reset --hard origin/master && git clean -f -d
}
function git-revert-and-sync-branch() {
git fetch origin && git reset --hard origin/$1 && git clean -f -d
}
function git-merge-to-master() {
git checkout master
git merge $1
echo "Waiting 15s to confirm the git push"
sleep 15
git push -u origin master
echo "Waiting 10s to confirm the git branch delete"
sleep 10
git branch -d $1
}
function git-config() {
git config --global user.name "Sriram S"
git config --global user.email sriram@cloudbuilder.in
}