Learn to build Git helpers with fzf and Bash from scratch.
This repository contains the code examples from the blog post: Build Git helpers from scratch with Bash and fzf.
- How to combine
fzfwith Git commands - Writing Bash functions (with some scripting tips)
- Building interactive branch switchers
- Creating safe deletion helpers with confirmation
- Making a commit selection tool for rebasing
-
Install fzf: check out the installation instructions for fzf.
-
Clone this repository:
git clone https://github.com/yourusername/fzf-git-tutorial.git cd fzf-git-tutorial -
Source the helpers
Add this to your
~/.bashrc(or~/.bash_profile):# in your ~/.bashrc source /path/to/fzf-git-tutorial/.bash_helpers
Then reload your shell:
source ~/.bashrc
-
Try the helpers (in any Git repository):
sfb # Switch to a branch using fzf dfb # Delete a branch with confirmation gri # Interactive rebase commit selection
.bash_helpers- All the Git helper functions
Interactive branch switcher using fzf. Shows all local branches with tracking info and switches to your selection.
Safe branch deletion with fzf selection and confirmation prompt.
Choose a commit to rebase onto using fzf with colored Git log output.
This repository is designed for learning and exploring Bash scripting with fzf. For a more robust and feature-rich solution, check out fzf-git.sh.
- Bash (tested with 5.2+)
- fzf (tested with 0.65+)
- Git
Read the full tutorial: "Build Git helpers from scratch with Bash and fzf".
MIT