unixorn/git-extra-commands

View on GitHub
bin/git-switch-branch

Summary

Maintainability
Test Coverage
#!/usr/bin/env bash
#
# Make it easier to switch to a branch by a substring of its
# name. More useful if you are good about deleting branches
# which have been merged upstream and if your branch names include
# unique identifiers like ticket/issue numbers.
#
# Source: https://github.com/Andrew565/dotfiles

BRANCH=$(git branch | grep -m 1 "$1") # Return only the first match
exec git checkout "$BRANCH"