To summarize the answers, here are the ways to accomplish this:
Vanilla Terminal Vim in a shell with job control
Press CTRL-Z in normal mode will drop you back in to the shell and suspend Vim. After executing your
git checkout [branchname], run the
fg builtin to return to the suspended Vim which will also force Vim to refresh (
It is also noteworthy that the
:checktime command in Vim will perform a buffer scan to see what filesystem changes there have been. See
:help :checktime for more info.
In vim 8, you can use
:terminal to start a shell, or
:terminal git checkout [branchname] to run one command. Neither will automatically
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).
plugin-fugitive is a plugin that allows you to use Git from within Vim. The command would be:
:Git checkout [branchname]
vim-merginal is a plugin that uses plugin-fugitive and provides a user friendly-ish interface.
- Move cursor to the branch you want.
cc to check out that branch.