无法签出git分支-需要提交更改,但不存在更改 [英] can't checkout a git branch - need to commit changes, but no changes are present

查看:94
本文介绍了无法签出git分支-需要提交更改,但不存在更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试签出分支时遇到问题,但我不能这样做,因为:

I'm having an issue where I'm trying to checkout a branch, but I can't because:

您对以下文件的本地更改将被覆盖 退房: lib/file.php请提交更改或隐藏更改,然后才能切换分支.中止

Your local changes to the following files would be overwritten by checkout: lib/file.php Please commit your changes or stash them before you can switch branches. Aborting

好,所以我运行git status,然后得到:

Ok, so I run git status, and I get:

在分支当前分支上没有要提交的内容,工作目录很干净

On branch current-branch nothing to commit, working directory clean

我需要编辑.git/info/exclude以排除lib/file.php,因为该文件在我的特定机器上引起了问题.但是,当我导航为排除时,我不再看到列出的文件.我检查了当前处于活动状态的所有三个分支,但在我的排除文件中没有看到lib/file.php.

I needed to edit .git/info/exclude to exclude lib/file.php because that file was causing problems on my specific machine. But when I navigate to exclude, I don't see the file listed anymore. I checked all three branches that are currently active but I don't see lib/file.php listed in my exclude file.

这是怎么回事?

不可重复-答案/链接建议作者从未真正提交过文件.我理解这个概念.这是一个不同的问题.

Not a duplicate - answer/link suggested the author never actually commited files. I understand that concept. This is a different issue.

推荐答案

当前您在一个分支中,文件lib/file.php不在git中,而是在您的文件夹中.您要切换到的分支在git中具有相同的文件.如果git切换到该分支,那么您当前拥有的当前文件将永远丢失.

Currently you are on a branch where the file lib/file.php is not in git, but in your folder. The branch you want to switch to has the same file in git. If git switched to that branch, the current file you have right now would be lost forever.

git错误消息有点令人困惑.它应该告诉您在切换到该分支之前删除lib/file.php,或者1.添加文件,2.提交它,3.切换到其他分支.

The git error message is a bit confusing. It should tell you to either delete lib/file.php before switching to that branch, or 1. add the file, 2. commit it 3. switch to other branch.

这篇关于无法签出git分支-需要提交更改,但不存在更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆