Git无法切换分支,隐藏或签出

时间:2018-08-02 11:08:50

标签: git

我尝试将分支从master切换到dev

git checkout dev
error: Your local changes to the following files would be overwritten by 
checkout:
    vendor/symfony/console/Resources/bin/hiddeninput.exe
Please, commit your changes or stash them before you can switch 
branches.
Aborting

我尝试删除更改

git checkout vendor/symfony/console/Resources/bin/hiddeninput.exe
git checkout dev
error: Your local changes to the following files would be overwritten by checkout:
vendor/symfony/console/Resources/bin/hiddeninput.exe
Please, commit your changes or stash them before you can switch branches.
Aborting

我试图藏起来

git stash
    error: Your local changes to the following files would be overwritten by checkout:
vendor/symfony/console/Resources/bin/hiddeninput.exe
Please, commit your changes or stash them before you can switch branches.
Aborting

我试着忽略它

git update-index --assume-unchanged vendor/symfony/console/Resources/bin/hiddeninput.exe
git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
git checkout dev
error: Your local changes to the following files would be overwritten by checkout:
vendor/symfony/console/Resources/bin/hiddeninput.exe
Please, commit your changes or stash them before you can switch branches.
Aborting

有什么建议吗?

2 个答案:

答案 0 :(得分:1)

前一段时间,我遇到了类似的问题。事实证明,文件的行尾会自动更改(由文件中的行尾混合引起)。可以使用-

进行验证
git config core.autocrlf

为了解决此问题,请将core.autocrlf设置为false。

git config --global core.autocrlf false

尝试在此之后执行git checkout您的文件名。 希望这可以帮助。

答案 1 :(得分:0)

第一人,add(现在statged进行更改,然后执行stash

$ git add -A          # stage the changes
$ git stash           
$ git checkout dev

或者,您可以hard reset做您的HEAD,然后尝试结帐:

$ git add -A
$ git reset --hard HEAD
$ git checkout dev