config/git: Update aliases & some config

This commit is contained in:
xerus2000 2020-09-04 12:15:05 +02:00
parent b8d303e08c
commit 9eb1e304b0
2 changed files with 63 additions and 40 deletions

View File

@ -9,6 +9,11 @@
[pack] [pack]
threads = 0 threads = 0
[pull]
ff = only
[checkout]
defaultRemote = origin
[diff] [diff]
tool = nvim tool = nvim
[merge] [merge]
@ -37,23 +42,62 @@
email = 27jf@pm.me email = 27jf@pm.me
name = xerus2000 name = xerus2000
[mailmap]
file = /home/janek/.config/yadm/.mailmap
[http]
lowSpeedLimit = 1000
lowSpeedTime = 3
[alias] [alias]
st = status -sb st = status -sb
stv = --paginate status -v stv = --paginate status -v
stvv = --paginate status -vv stvv = --paginate status -vv
l = !git --no-pager log --pretty=tformat:'%C(auto)%h -%d %s %Cgreen(%cr) %Cblue<%an>%Creset' -5
unstage = reset HEAD -- r = remote -v
ready = rebase -i @{u} b = branch -vv
ref = reflog
curbranch = symbolic-ref --short HEAD rev = rev-parse --short
head = rev-parse --short HEAD
root = rev-parse --show-toplevel root = rev-parse --show-toplevel
curbranch = symbolic-ref --short HEAD
lo = log --pretty=tformat:'%C(auto)%h -%d %s %Cgreen(%cd) %Cblue<%an>%Creset' --date=human --no-merges
l = !git --no-pager lo -5
my = lo --author erus
standup = lo --since yesterday --author erus --all
co-authors = !git log | grep -i Co-Authored | awk '!a[$0]++'
# List all branches with their last updates
when = git for-each-ref --sort=committerdate --format='%(refname:short) * %(authorname) * %(committerdate:relative)' refs/remotes/
dir = !git root | sed 's/$/\\/.git/' | grep --color=never "/" # grep ensures a proper exit status on fail dir = !git root | sed 's/$/\\/.git/' | grep --color=never "/" # grep ensures a proper exit status on fail
upstream = !git rev-parse --abbrev-ref --symbolic-full-name @{u} || echo origin/$(git curbranch)
c = commit
co = checkout
cp = cherry-pick
p = push
pf = push --force-with-lease
fs = !git fetch && git st
lu = !git pull upstream $(git curbranch)
luu = !git pull upstream $(git curbranch) && git push --no-verify
rh = reset HEAD~
rhh = reset --hard
rhhu = !git reset --hard $(git upstream)
unstage = reset HEAD --
gcr = !git gc && git repack -a -d
ready = rebase -i @{u}
format-head = !git stash && git-clang-format HEAD~ && git commit -a --amend --no-edit && git stash pop
# yadm
add-git = !git add $XDG_CONFIG_HOME/git/config $CONFIG_SHELLS/git
add-vim = !git add $XDG_CONFIG_HOME/nvim/init*
[filter "lfs"] [filter "lfs"]
clean = git-lfs clean -- %f clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f smudge = git-lfs smudge -- %f
process = git-lfs filter-process process = git-lfs filter-process
required = true required = true
[pull]
ff = only

View File

@ -1,5 +1,5 @@
# Tools # Tools
alias bfg='java -jar ~/daten/dropbox/tools/bfg-1.13.0.jar' alias bfg="java -jar $HOME/daten/applications/bfg-1.13.0.jar"
alias magit='nvim -c MagitOnly' alias magit='nvim -c MagitOnly'
# if in home or under XDG_CONFIG_HOME and not within a git directory, replace git by yadm # if in home or under XDG_CONFIG_HOME and not within a git directory, replace git by yadm
@ -19,42 +19,21 @@ git() {
command git "$@"; command git "$@";
} }
# Repo info # Log local and upstream commits side by side - useful to check before forcing an action
alias gr='git remote -v'
alias gb='git branch -vv'
alias grev='git rev-parse --short'
alias ghead='git rev-parse --short HEAD'
alias gref='git reflog'
# Show the 5 most recent commits without pager
alias gln='git --no-pager log --pretty=tformat:"%C(auto)%h -%d %s %Cgreen(%cr) %Cblue<%an>%Creset" -5'
# Log local and origin commits side by side - useful to check before forcing an action
glno() { glno() {
loc="$(git log --pretty=format:"%C(auto)%h %s %Cgreen(%cr)" -5 "$@" --color=always "$@")" loc="$(git l --color=always "$@")"
origin="$(git log --pretty=format:"%C(auto)%h %s %Cgreen(%cr)" -5 "origin/$(git curbranch)" --color=always "$@")" upstream="$(git l --color=always $(git upstream) "$@")"
a=$(echo $loc | wc -l) a=$(echo $loc | wc -l)
b=$(echo $origin | wc -l) b=$(echo $upstream | wc -l)
halfcols="$(($(tput cols) / 2))" halfcols="$(($(tput cols) / 2))"
for i in `seq 1 $([ $a -le $b ] && echo "$a" || echo "$b")`; do for i in `seq 1 $([ $a -le $b ] && echo "$a" || echo "$b")`; do
printf "%-${halfcols}s %s\n" "$(echo $loc | head -n $i | tail -1)" "$(echo $origin | head -n $i | tail -1)" printf "%-${halfcols}s %s\n" "$(echo $loc | head -n $i | tail -1)" "$(echo $upstream | head -n $i | tail -1)"
done done
} }
# Shortcuts # Shortcuts
alias gfs='git fetch && git status -s -b'
alias glu='git pull upstream $(git curbranch)'
alias gluu='git pull upstream $(git curbranch) && git push --no-verify'
alias gcap!='git commit --all --amend --no-edit && git push --force-with-lease' alias gcap!='git commit --all --amend --no-edit && git push --force-with-lease'
alias gpf='git push --force-with-lease' gitweek() { git my --after "$(date -d "Mon ${1:-1} weeks ago")" --before "$(date -d "Mon $(expr ${1:-1} - 1) weeks ago")" "${@:2}" }
alias grh='git reset HEAD~'
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'
alias gitstandup='git --no-pager log --since yesterday --author erus --all'
alias gitready='git rebase -i @{u}'
# List all branches with their last updates
alias gitwhen="git for-each-ref --sort=committerdate --format='%(refname:short) * %(authorname) * %(committerdate:relative)' refs/remotes/"
# Find a commit that follows the given one - second argument can be used to specify the search range # Find a commit that follows the given one - second argument can be used to specify the search range
gitchild() { git log --reverse --ancestry-path --pretty=%H $1..${2:-HEAD} | head -1; } gitchild() { git log --reverse --ancestry-path --pretty=%H $1..${2:-HEAD} | head -1; }
@ -79,7 +58,7 @@ gitrebranch() {
} }
gitrmbranch() { gitrmbranch() {
branch=${1:-$(git curbranch)} branch=${1:-$(git curbranch)}
git push -d origin $branch git push -d $(git rev-parse --abbrev-ref $branch@{u} | sed 's/\// /' || echo origin $branch)
test $1 || git checkout master || git checkout $(cat .git/refs/remotes/origin/HEAD | cut -d'/' -f4) test $1 || git checkout master || git checkout $(cat .git/refs/remotes/origin/HEAD | cut -d'/' -f4)
git branch -D $branch git branch -D $branch
} }
@ -112,7 +91,7 @@ gitinit() {
gitbackup() { gitbackup() {
p=$(basename $PWD) p=$(basename $PWD)
cd .. builtin cd ..
git clone --mirror $p git clone --mirror $p
cd $p cd $p
} }
@ -138,13 +117,13 @@ gitremote() {
gitclone() { gitclone() {
remote=$(gitremote "$@") remote=$(gitremote "$@")
echo $remote echo $remote
git clone $remote "${@:4}" git clone $remote ${@:4}
cd "$(test $4 && echo $4 || basename ${remote/.git})" cd "$(test $4 && echo $4 || basename ${remote/.git})"
} }
gitfork() { gitfork() {
cd "$projects_dir/_forks" builtin cd "$projects_dir/_forks"
gitclone hub "$1" gitclone hub "$1" "" "$3" --recurse-submodules
test "$2" && git remote add upstream "$(gitremote hub "$1" "$2")" test "$2" && git remote add upstream "$(gitremote hub "$1" "$2")"
git remote -v git remote -v
} }