-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-aliases.sh
More file actions
54 lines (45 loc) · 1.31 KB
/
git-aliases.sh
File metadata and controls
54 lines (45 loc) · 1.31 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
#!/bin/bash
# Fix common typos ;-)
alias gti=git
alias gs="git status"
alias gc="git add . && git commit -m"
alias co="git checkout"
alias master="co master"
alias main="co main"
alias develop="co develop"
alias reset="git reset --hard"
alias cleanf="git clean -f -d"
alias pull="git pull"
alias pullf="git reset --hard origin/develop"
alias bl="git branch --list"
alias push=push-origin
alias pushnv=push-origin-no-verify
alias cb=copy-branch-name-to-clipboard
# Helper fns
# Returns current branch name
function get-branch-name {
echo "$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)"
}
# Simple rebase shortcut
function rebase {
branch_name="$(get-branch-name)"
git checkout main
git pull
git checkout ${branch_name}
git merge main
}
# Push current branch to orgin without providing "--set-upstream origin" every time
function push-origin {
branch_name="$(get-branch-name)"
git push --set-upstream origin ${branch_name}
}
# Same as "push-origin" but bypass pre-push checks (set up with Husky i.e.)
function push-origin-no-verify {
branch_name="$(get-branch-name)"
git push --set-upstream origin ${branch-name} --no-verify
}
function copy-branch-name-to-clipboard {
branch_name="$(get-branch-name)"
echo ${branch_name} | pbcopy
echo Copied ${branch_name} to clipboard!
}