config/git: migrate log and caching shell aliases to bins
This commit is contained in:
parent
ff04aba675
commit
2527d2630d
|
@ -24,7 +24,7 @@ git() {
|
|||
command git "$@";
|
||||
}
|
||||
|
||||
# Log local and upstream commits side by side - useful to check before forcing an action
|
||||
# Log local and upstream commits side by side - useful to check when the history has been manipulated
|
||||
glno() {
|
||||
loc="$(git l --color=always "$@")"
|
||||
upstream="$(git l --color=always $(git upstream) "$@")"
|
||||
|
@ -36,23 +36,6 @@ glno() {
|
|||
done
|
||||
}
|
||||
|
||||
# Shortcuts
|
||||
alias gcap!='git commit --all --amend --no-edit && 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}" }
|
||||
# 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; }
|
||||
|
||||
# Caching
|
||||
gitrecache() {
|
||||
git rm --cached --quiet -r ${1:-.}
|
||||
git add ${1:-.}
|
||||
git status -s
|
||||
}
|
||||
gitrestore() {
|
||||
git reset -- "$@"
|
||||
git checkout -- "$@"
|
||||
}
|
||||
|
||||
# BRANCHES
|
||||
# Cleans up remote branches and removes branches where the remote-tracking branches got removed.
|
||||
alias gitrmgonebranches='git fetch -p && for branch in `git branch -vv | grep ": gone]" | cut -d" " -f3`; do git branch -D "$branch"; done'
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
# Find a commit that follows the given one
|
||||
# Second argument can be used to specify the search range - default HEAD
|
||||
git log --reverse --ancestry-path --pretty=%H $1..${2:-HEAD} | head -1
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
# Restores the repository version of given files
|
||||
git reset -- "$@"
|
||||
git checkout -- "$@"
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Untracks and adds back all files (or the given path)
|
||||
# Useful to remove tracked files after adding them to the gitignore
|
||||
git rm --cached --quiet -r ${1:-.}
|
||||
git add ${1:-.}
|
||||
git status -s
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
# Commits by myself throughout the current week
|
||||
# Depends on git-my alias listing commits by myself
|
||||
git my --after "$(date -d "Mon ${1:-1} weeks ago")" --before "$(date -d "Mon $(expr ${1:-1} - 1) weeks ago")" "${@:2}"
|
Loading…
Reference in New Issue