git: Use switch instead of checkout if available
For git versions that support it, the aliases will use the newer `switch` instruction instead of `checkout` for its use cases. Creating a new branch through `gcb` is for example done by `git switch -c` instead of the older `git checkout -b`. Additionally streamlined git version checking to be a little faster and to unify its approach on posix sh, bash and zsh instead of utilizing individual checking functions.
This commit is contained in:
parent
cf85357f5c
commit
df0cf3d540
3 changed files with 21 additions and 30 deletions
|
|
@ -1,15 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
# shellcheck shell=sh
|
||||
|
||||
if ! exist git; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# git alias
|
||||
# if git is at least version 2.13, we can use git stash push
|
||||
autoload -Uz is-at-least
|
||||
if is-at-least 2.13 "$(git --version 2>/dev/null | awk '{print $3}')"; then
|
||||
alias gsta='git stash push'
|
||||
else
|
||||
alias gsta='git stash save'
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue