-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.sh
executable file
·70 lines (61 loc) · 1.61 KB
/
git.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# GENERIC git functions and aliases
# github
alias github="open https://github.com/"
# git
alias gi="git init"
alias ga="git add ."
alias gs="git status"
alias gb="git branch -a"
alias unstage="git reset HEAD -- ."
# cos my fingers can't reach 'p'!
alias gush="git push"
alias gull="git pull"
# pretty logging
alias glog="git log --graph --pretty=oneline --abbrev-commit"
# git commit with short log message
# gc() {
# git commit -m "$1"
# }
# # revert un-committed changes to repo
function grev() {
read -p "Drop changes and return to the last committed state - continue? (y/n)" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo ""
git checkout -f ; git reset --hard
fi
}
# add all changes, push with specified commit message
function gup() {
ga;
gc $1;
gush;
}
function gclean() {
read -p "remove all branches that have been merged to *master*? (y/n)" -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
fi
}
# function gfind() {
# # Find Git commit that introduced a string in any branch
# # git log -S $1 --source --all
# # Find Git commit that introduced a string in current branch
# git log -S $1 --source
# }
# # get rid of merged local branches
# function gclean() {
# currentbranch=$(git branch --merged | grep "\*")
# echo $currentbranch
# pwd
# if [[ $currentbranch != '* master' ]]
# then
# echo 'not master'
# else
# echo 'master branch'
# fi
# # git branch --merged master | grep -v "\* master" | xargs -n 1 git branch -d
# # $ git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
# }