git无法切换分支(git checkout)解决办法

git在切换分支时,

        gitbash窗口中报错 :

                Segmentation fault错误,

                或者报错:Another git process semms to be running in this repository, e.g. an editor opened by ‘git commit’. Please make sure all processes are terminated then try again. If it still fails, a git process remove the file manually to continue.
将index.lock删除后,仍然无法

        idea中报错:

                Couldn't checkout original/dev,Unable to create '项目目录/.git/index.lock':File exists.

手动删除 项目目录/.git/index.lock(如果未显示,需要打开windows隐藏目录选项,.git文件夹默认为隐藏不显示)仍然报上面错误,无法切换分支。

这时,需要将.git目录下的index文件和index.lock两个文件一起删除,再执行 git checkout -f 分支名,即可成功切换分支。网上说需要重装git之类的,完全没必要费这么大周折,走那么大弯路。

 

你可能感兴趣的:(git,git,github,java)