-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit.sh
More file actions
executable file
·24 lines (21 loc) · 769 Bytes
/
git.sh
File metadata and controls
executable file
·24 lines (21 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
alias apply='git cherry-pick'
function pull()
{
GIT_BRANCH="$(git branch --show-current)"
[[ -z "$GIT_BRANCH" ]] || git pull origin "$GIT_BRANCH"
git submodule update --init --recursive
}
function push()
{
GIT_BRANCH="$(git branch --show-current)"
if [[ "$(echo "$GIT_BRANCH" | grep -cP '^(develop|main|master)$')" == '1' && "$1" != "$GIT_BRANCH" ]]; then
printf "\e[31mERROR: Yer on $GIT_BRANCH"'!\e[0m\n'
echo "If you really want to push to $GIT_BRANCH, show you mean it:"
echo "$ push $GIT_BRANCH"
return 1
fi
git push $([[ "$(echo $1 | grep -cP '^-*f(orce)?$')" != '0' ]] && echo '--force ')origin "$(git branch --show-current)"
}
alias staged='git diff --staged'
alias status='git status'