Skip to content

Instantly share code, notes, and snippets.

@wteuber
Last active November 14, 2023 12:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wteuber/6fd3488c1c8f4809d5964bedc40dd210 to your computer and use it in GitHub Desktop.
Save wteuber/6fd3488c1c8f4809d5964bedc40dd210 to your computer and use it in GitHub Desktop.
git aliases
# Print origin/HEAD branch name (default branch)
gdb() {
git remote show origin | grep 'HEAD branch' | cut -d ' ' -f5
}
# Print origin/HEAD branch name (default branch)
# uses ohmyzsh git plugin aliases https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/git/git.plugin.zsh
gcdb() {
gco `gdb`
}
# git tree https://github.com/knugie/git-status-tree
gt() {
if [[ $(git config --get-regexp ^alias.tree) ]]; then
git tree
else
echo "git tree is not registered, to install run\ngem install git-status-tree"
fi
}
# Create new branch from previous commit message
# uses ohmyzsh git plugin aliases https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/git/git.plugin.zsh
gcbfc() {
gcb `git log -1 --pretty=%s | tr -sc '[:alnum:]' ' ' | tr '[:upper:]' '[:lower:]' | xargs | tr ' ' '-'`
}
gddb() {
git diff-tree --name-status -r $(git merge-base HEAD origin/`gdb`) HEAD
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment