# Git Fuzzy Checkout
#
# Add the following script to your ~/.gitconfig by run:
# git config --global alias.fuzzy '!f() { git branch -a | grep -m1 -e ${1}.*${2} | sed "s/remotes\/origin\///" | xargs git checkout; }; f'
#
# alias of .gitconfig looks:
[alias]
# fuzzy checkout branch, e.g: git fc feature 739, will checkout branch feature/PGIA-739-deploy-maximum
fc = "!f() { git branch -a | grep -m1 -e ${1}.*${2} | sed \"s/remotes\\/origin\\///\" | xargs git checkout; }; f"
# or
# fc = "!f() { git branch -a | grep -m1 -e ${1}.*${2} | sed 's/remotes\\/origin\\///' | xargs git checkout; }; f"
#
# README
#
# If you want to checkout branch feature/PGIA-739-deploy-maximum
# you can run
# git fc feature 739
# or
# git fc 739
# git fc will find and checkout the first match branch
#
#
# others useful alias
# Squash the last N commits to 1 commit
squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
last = log -1 HEAD
ls = "!f() { git log --graph --date=relative --pretty=tformat:'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%an %ad)%Creset'; };f"
# Find the branch
fb = "!f() { git branch -a | grep ${1} --color=auto ;}; f"