Skip to content

Commit

Permalink
Latest git config improvements (#58)
Browse files Browse the repository at this point in the history
- Alias to switch to default origin branch
- Alias to test ssh connection to github
- Remove unnecessary echos in aliases
- Disable detached head and empty pathspec advices
  • Loading branch information
kucera-lukas authored Jan 1, 2025
1 parent 7f91125 commit 81fe90b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Empty file added .git-blame-ignore-revs
Empty file.
15 changes: 11 additions & 4 deletions home/dot_config/git/config.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,18 @@
staged = diff --cached
stashed = !git --no-pager stash list
tags = tag -n1 -l
trash = !git restore --staged --worktree --source HEAD -- . && echo 'Trashed all changes'
nuke = !git reset --hard HEAD~1 && echo 'Nuked last commit'
restart = !git reset --hard @{upstream} && echo 'Restarted to upstream branch'
trash = !git restore --staged --worktree --source HEAD -- .
nuke = !git reset --hard HEAD~1
restart = !git reset --hard @{upstream}
type = cat-file -t
unstage = reset HEAD .
root = rev-parse --show-toplevel
git = !git
# inspired by https://stackoverflow.com/a/53597426
amend-to = "!f() { current_branch=\"$(git rev-parse --abbrev-ref HEAD)\" && apply_to=\"$1\" && git stash --quiet && git checkout --quiet \"$apply_to\" && git stash apply --quiet && git add -u && git commit --quiet --amend --no-edit && new_sha=\"$(git log --format=\"%H\" -n 1)\" && git switch --quiet \"$current_branch\" && git rebase --quiet --onto \"$new_sha\" \"$apply_to\" && echo \"Amended changes to $apply_to\"; }; f $1"
amend-to = "!f() { current_branch=\"$(git rev-parse --abbrev-ref HEAD)\" && apply_to=\"$1\" && git stash --quiet && git checkout --quiet \"$apply_to\" && git stash apply --quiet && git add -u && git commit --quiet --amend --no-edit && new_sha=\"$(git log --format=\"%H\" -n 1)\" && git switch --quiet \"$current_branch\" && git rebase --quiet --onto \"$new_sha\" \"$apply_to\"; }; f $1"
# inspired by https://stackoverflow.com/questions/28666357/how-to-get-default-git-branch#comment126528129_50056710
origin = "!sh -c \"git switch $(LC_ALL=C git remote show origin | sed -n '/HEAD branch/s/.*: //p')\""
github = !sh -c 'ssh -T git@github.com'

[color]
advice = true
Expand Down Expand Up @@ -281,6 +284,10 @@
showUntrackedFiles = all
renames = copies

[advice]
addEmptyPathspec = false
detachedHead = false

[diff]
colorMoved = default
renames = copies
Expand Down

0 comments on commit 81fe90b

Please sign in to comment.