-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.bash
More file actions
61 lines (48 loc) · 1.27 KB
/
git.bash
File metadata and controls
61 lines (48 loc) · 1.27 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
#!/bin/bash
# Add ssh-key
eval && ssh-add "$HOME/.ssh/id_rsa"
# LazyGit
alias lg="lazygit"
alias gs="lg status"
alias lgl="lg log"
alias lgb="lg branch"
alias lgst="lg stash"
# Git
alias g="git"
alias gP="g pull"
alias gc="g commit --no-verify -m"
alias gd="g diff -w"
alias gds="g diff --stat"
alias gch="g checkout"
alias grh="g reset --hard && gclean"
alias gpa="git-pull-all"
alias gb="git branch --all | fzf --header 'Select branch to checkout:' --preview 'git show --color=always {-1}' --bind 'enter:become(git checkout {-1})' --height 50% --layout reverse"
alias gclean="g clean -f"
alias gst="g status"
alias gcwip="g add . && g status && gc wip && gp"
function gdw() {
SEARCH=$1
if [[ ! $SEARCH ]]; then
echo "Usage: gdw <string>"
return
fi
gd "*$SEARCH*"
}
# Create and push a tag to Bitbcket
function gt() {
g tag "$1" && g push origin "$1"
}
# Commit and push the changes
function gP() {
if [ -n "$1" ]; then
gc "$1"
fi
# Check if the current branch has an upstream branch
CURRENT_BRANCH=$(git symbolic-ref --short HEAD)
if [ -z "$(git config branch.${CURRENT_BRANCH}.remote)" ]; then
echo "No upstream branch set for ${CURRENT_BRANCH}. Setting it now..."
git push --set-upstream origin "$CURRENT_BRANCH"
else
g push origin
fi
}