Skip to content

Instantly share code, notes, and snippets.

View DanilaMihailov's full-sized avatar
💻
Weeks of coding can save you hours of planning

Danila Mihailov DanilaMihailov

💻
Weeks of coding can save you hours of planning
View GitHub Profile
@DanilaMihailov
DanilaMihailov / fzf-branch-checkout.vim
Last active April 22, 2022 20:45
Select and checkout git branch using fzf in Vim
function! GitCheckoutBranch(branch)
" branch can look like this: "/remotes/origin/master [hash] info" or this: "master [hash] info"
let l:name = split(split(trim(a:branch), "", 1)[0], "/", 1)[-1]
" just show what is happening
echo "checking out ".l:name."\n"
" you can use !git, instead of Git, if you don't have Fugitive
execute "Git checkout ".l:name
endfunction