Closed GreenSleeper closed 7 months ago
I will comment here since it's worktree related. I keep my worktrees inside the main repo (so ~/repo/worktree1
, ~/repo/worktree2
, ...) with ~/repo
set to a dummy branch.
fzf-git.sh
uses git rev-parse HEAD
to check for a git repo but this fails on my ~/repo
, a more robust alternative is git rev-parse --show-toplevel
.
@andreabedini What's the error message? I tried creating a few worktrees and I don't see any problem. Can you provide minimal steps to reproduce the problem you described?
Adding a binding for worktrees is easy. In its simplest form, this is all you need.
_fzf_git_worktrees() {
_fzf_git_check || return
git worktree list | _fzf_git_fzf "$@" | awk '{print $1}'
}
__fzf_git_init worktrees
Then you can use <CTRL-G><CTRL-W>
binding.
cd <CTRL-G><CTRL-W>
switch support
fzf-git project is for adding shortcuts to auto-complete Git objects on the command-line. It isn't for providing shortcut routines. e.g. switch branches, switch worktrees, etc. But you can define functions like this:
swt() {
cd "$(_fzf_git_worktrees)"
}
@andreabedini What's the error message? I tried creating a few worktrees and I don't see any problem. Can you provide minimal steps to reproduce the problem you described?
Sorry I had not been clear. There's no error message, but in my (peculiar if you want) situation ~/repo
is a branch with no commits, so git rev-parse HEAD
fails, with git rev-parse --show-toplevel
works and returns ~/repo
.
Thank you for this project! :relaxed:
Any intention to add worktree folder switch support?