Git cannot switch branches (git checkout) solution

When git switches branches,

        An error is reported in the gitbash window:

                Segmentation fault error,

                或者报错: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删除后,仍然无法

        Error reported in idea:

                Couldn't checkout original/dev, Unable to create 'project directory/.git/index.lock':File exists.

Manually delete the project directory /.git/index.lock (if it is not displayed, you need to turn on the Windows hidden directory option, the .git folder is hidden by default and not displayed) still report the above error and cannot switch branches.

At this time, you need to delete the index file and index.lock file in the .git directory together, and then execute git checkout -f branch name to successfully switch branches. It is said on the Internet that git needs to be reinstalled. There is no need to go through such a big trouble and take such a big detour.

 

Guess you like

Origin blog.csdn.net/weixin_41267342/article/details/127562949