[git] Fix git stash alias,set default pull options

Fixed git stash alias (gsta) not correctly detecting zsh shell for git
version guessing.

Set default options to automatically rebase on pull, automatically prune
on fetch, and automatically stash and squash on rebasing.

Also made git diff highlight moved code.
This commit is contained in:
Marty Oehme 2020-05-25 17:36:27 +02:00
parent 86fa743988
commit e9feecc440
No known key found for this signature in database
GPG Key ID: 0CCB0526EFB9611A
2 changed files with 24 additions and 7 deletions

View File

@ -10,6 +10,23 @@
[alias]
ignore = "!gitignore -f"
pushmerge = "push -o merge_request.merge_when_pipeline_succeeds" # see https://docs.gitlab.com/ce/user/project/push_options.html#merge-when-pipeline-succeeds-alias
[commit]
# sign commits as me
gpgsign = true
# Always show diff when preparing commit message
verbose = true
[fetch]
# remove references to non-existent remote branches
prune = true
[pull]
rebase = true # always rebase on pulling, obviates merge commits
[diff]
colorMoved = zebra # also color stuff that has simply been moved, in a classy zebra-color
[rebase]
autostash = true
autoSquash = true
# Make use of git urls for git{lab,hub}, but only do so for pushing
# since pulling will create troubles with some applications
[url "git@github.com:"]
pushInsteadOf = "https://github.com/"
pushInsteadOf = "http://github.com/"
@ -17,8 +34,3 @@
[url "git@gitlab.com:"]
pushInsteadOf = "https://gitlab.com"
pushInsteadOf = "http://gitlab.com"
[commit]
# sign commits as me
gpgsign = true
# Show diff when preparing commit message
verbose = true

View File

@ -47,14 +47,19 @@ if exist git; then
alias gst='git status'
if [ "$0" = "/bin/zsh" ]; then
# if git is at least version 2.13, we can use git stash push
# in shells other than zsh, simply fall back to save
case "$(ps -cp "$$" -o command="")" in
*zsh*)
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
fi
;;
*) alias gsta='git stash save' ;;
esac
alias gstp='git stash pop'
alias gstl='git stash list'
fi