Git: improve config & add yadm fallback

This commit is contained in:
xerus2000 2020-06-08 11:42:34 +02:00
parent a98234a870
commit d1aeb2535b
2 changed files with 19 additions and 3 deletions

View File

@ -41,17 +41,19 @@
st = status -sb
stv = --paginate status -v
stvv = --paginate status -vv
ln = !git --no-pager log --pretty=tformat:'%C(auto)%h -%d %s %Cgreen(%cr) %Cblue<%an>%Creset' -5
l = !git --no-pager log --pretty=tformat:'%C(auto)%h -%d %s %Cgreen(%cr) %Cblue<%an>%Creset' -5
unstage = reset HEAD --
ready = rebase -i @{u}
curbranch = symbolic-ref --short HEAD
root = rev-parse --show-toplevel
dir = !git root | sed 's/$/\\/.git/g'
dir = !git root | sed 's/$/\\/.git/' | grep --color=never "/" # grep ensures a proper exit status on fail
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[pull]
ff = only

View File

@ -2,6 +2,18 @@
alias bfg='java -jar ~/daten/dropbox/tools/bfg-1.13.0.jar'
alias magit='nvim -c MagitOnly'
# if in home or xdg-config and not within a git directory, replace git by yadm
git() {
case "$PWD" in
~|$(xdg-user-dir CONFIG)*)
if ! command git rev-parse --show-toplevel 2&>/dev/null; then
yadm "$@"
return
fi;;
esac
command git "$@";
}
# Repo info
alias gr='git remote -v'
alias gb='git branch -vv'
@ -27,7 +39,8 @@ glno() {
# Shortcuts
alias gfs='git fetch && git status -s -b'
alias glu='git pull upstream $(git curbranch)'
alias gcap!='git commit -a --amend --no-edit && git push -f'
alias gluu='git pull upstream $(git curbranch) && git push --no-verify'
alias gcap!='git commit -a --amend --no-edit && git push --force-with-lease'
alias grh!='git reset --hard'
alias grhr='git reset --hard $(git rev-parse --abbrev-ref --symbolic-full-name @{u})'
alias gitgc='git gc && git repack -a -d'
@ -108,6 +121,7 @@ project() {
gitremote() {
case "$1" in
http*) echo "git@$(echo "$1" | cut -d'/' -f3):$(echo "$1" | cut -d'/' -f4)/$(echo "$1" | cut -d'/' -f5)" ;;
git:*) echo "$1" ;;
*) test "$3" = "cau" && 3="CAU-Kiel-Tech-Inf"
test "$3" = "btl" && 3="betweenthelinesev"
echo "git@git${1:-hub}.com:${3:-xerus2000}/${2:-$(basename $PWD)}.git" ;;