/git_worktree_fzf

git worktree add/remove fuzzy search on shell

Primary LanguageShellThe UnlicenseUnlicense

git worktree fzf with my 🫰

  • I'm test it worked on bash maybe zsh will work.
  • Fish and other shell can be support later if i not lazy, pull request are welcome🫰
  • Video: https://youtu.be/B39zBcK6x5w

Install

curl --remote-name https://raw.githubusercontent.com/thuanowa/git_worktree_fzf/master/git_worktree_fzf.bash > ~/.local/share/git_worktree_fzf.bash

echo "source ~/.local/share/git_worktree_fzf.bash" >> ~/.bashrc
source ~/.bashrc 

OR

How to use?

worktree will be stored at .worktrees:

git_folder
--- README.md
--- .worktrees/feat/here
--- .worktrees/tmp

Ignore .worktrees/ globally

~/.gitconfig

[core]
excludesfile = ~/.gitignore

~/.gitignore

.worktrees/

Function

  • The script have 2 functions:
    1. fzf_git_worktree_change_dir
    2. fzf_git_worktree_remove
  • you can make the alias of that like me.
alias w="fzf_git_worktree_change_dir"
alias ww="fzf_git_worktree_remove"

fzf_git_worktree_change_dir

  • Show all your git worktree
  • Search your worktrees with fzf
  1. if had, change dir to your worktree location
  2. if the name of worktree you type don't have -> just press enter it will create new git worktree with the name you provice for you.

fzf_git_worktree_remove

  • Show all your git worktree
  • Search your worktrees with fzf, find the worktree you want remove, press enter will remove this worktree