Skip to content

Commit 81fe90b

Browse files
authored
Latest git config improvements (#58)
- 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
1 parent 7f91125 commit 81fe90b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.git-blame-ignore-revs

Whitespace-only changes.

home/dot_config/git/config.tmpl

+11-4
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,18 @@
185185
staged = diff --cached
186186
stashed = !git --no-pager stash list
187187
tags = tag -n1 -l
188-
trash = !git restore --staged --worktree --source HEAD -- . && echo 'Trashed all changes'
189-
nuke = !git reset --hard HEAD~1 && echo 'Nuked last commit'
190-
restart = !git reset --hard @{upstream} && echo 'Restarted to upstream branch'
188+
trash = !git restore --staged --worktree --source HEAD -- .
189+
nuke = !git reset --hard HEAD~1
190+
restart = !git reset --hard @{upstream}
191191
type = cat-file -t
192192
unstage = reset HEAD .
193193
root = rev-parse --show-toplevel
194194
git = !git
195195
# inspired by https://stackoverflow.com/a/53597426
196-
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"
196+
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"
197+
# inspired by https://stackoverflow.com/questions/28666357/how-to-get-default-git-branch#comment126528129_50056710
198+
origin = "!sh -c \"git switch $(LC_ALL=C git remote show origin | sed -n '/HEAD branch/s/.*: //p')\""
199+
github = !sh -c 'ssh -T [email protected]'
197200

198201
[color]
199202
advice = true
@@ -281,6 +284,10 @@
281284
showUntrackedFiles = all
282285
renames = copies
283286

287+
[advice]
288+
addEmptyPathspec = false
289+
detachedHead = false
290+
284291
[diff]
285292
colorMoved = default
286293
renames = copies

0 commit comments

Comments
 (0)