To culminate the answers here are the ways to accomplish this:
Vanilla Terminal Vim
Press CTRL-Z in normal mode will drop you back in to the shell and suspend Vim. After executing your git checkout [branchname]
type the fg
command to return to the suspended Vim which will also force Vim to refresh.
It is also noteworthy that the :checktime
command in Vim can come in handy to perform the buffer scan to what filesystem changes there have been. See :help :checktime
for more info.
Vanilla GUI Vim
Some gvim implementations will have :shell
support which will open a shell inside of Vim using a dumb terminal. However it may be easier to just type:
:!git checkout [branchname]
This will execute the command without having to open a new shell prompt. (This option is also usable in the terminal Vim).
vim-fugitive
vim-fugitive is a plugin that allows you to use Git from within Vim. The command would be:
:Git checkout [branchname]
vim-merginal
vim-merginal is a plugin that uses vim-fugitive and provides a user friendly-ish interface.
- Type
:Merginal
.
- Move cursor to the branch you want.
- Type
cc
to check out that branch.