Skip to content

Instantly share code, notes, and snippets.

@n1kk
Last active November 16, 2024 15:06
Show Gist options
  • Save n1kk/869c293646868aaa22fedad46e2e13d9 to your computer and use it in GitHub Desktop.
Save n1kk/869c293646868aaa22fedad46e2e13d9 to your computer and use it in GitHub Desktop.
my git aliases
[alias]
aliases = config --get-regexp alias
# fetch latest default branch and switch to it in one go
master = !git fetch origin master:master && git switch master
main = !git fetch origin main:main && git switch main
# push new local branch that does not exist on remote
publish = push -u origin HEAD
# remove all local branched that were deleted on remote
prune-branch = !git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -d
# start ssh agent to save git password for current session
# useage: eval `git agent`
agent = "!echo 'eval `ssh-agent`; ssh-add ~/.ssh/__YOUR_KEY__'"
# override for local repos that use other key
# agent = "!echo 'eval `ssh-agent`; ssh-add ~/.ssh/__SOME_OTHER__KEY'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment