Is it advisable to switch branches in GIT when files are opene开发者_开发问答d in your editor?
I have opened my project files in VIM on a number of tabs, and I want to quickly switch to a different branch, do I have to keep on closing my projects, switch a branch then reopen my project?
Vim should warn you, but if you want to be sure to reload every open buffer you can type:
:bufdo e
:e
will reload a file, :bufdo e
will reload every open buffer.
This can be a problem if your editor does not warn you when you try to save a file when it has been changed in the filesystem since it has been opened as you can lose work in the case.
There is also a potential problem on Windows as the editor may lock the file. If this is the case, git will be unable to update it and the switch will fail, leaving the working directory in an indeterminate state.
Apart from those issues (risk of losing change if you have unsaved modification, risk of failure if your editor is locking files), there is no problem using git command while you have files opened in your editor.
+1 Xavier for directing me to the right place, sorry i didn't mention that am using GVIM. My files are in TABS. So i learned you can use :tabdo e! to reload the TABS. :bufdo e reloads buffers.
Thanks guys.
精彩评论