工作树清理时检出错误

时间:2017-09-05 10:01:55

标签: git

请, 我收到错误“您对以下文件的本地更改将被结帐覆盖”但我的工作树是干净的。

有没有人知道这里发生了什么?

$ git status
On branch experiment
nothing to commit, working tree clean

$ git checkout develop
error: Your local changes to the following files would be overwritten by checkout:
app/build.gradle
Please commit your changes or stash them before you switch branches.
Aborting

(文件app/build.gradle不在我的.gitignore文件中)

这是顶级.gitignore文件:

### Android ###

# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
.idea
*.iml

# Keystore files
*.jks

# External native build folder generated in Android Studio 2.2 and     later
.externalNativeBuild

# Mac
.DS_Store

### Android Patch ###
gen-external-apklibs

这是/ app目录中的.gitignore文件(我不知道为什么会这样):

build

# Secrets
secrets.properties

2 个答案:

答案 0 :(得分:4)

疯狂的镜头:

我曾经读到一个隐藏的"假设未改变的旗帜" (见this answer for example),
我知道这个标志在文件上是否有效的唯一方法是(见this answer):

git ls-files -v | grep '^[[:lower:]]'

当您在回购邮件上运行上述命令时,您看到了什么?

答案 1 :(得分:-2)

做一个git状态 查看仍有待添加或更改的文件。

当有可以覆盖的本地cahnges时会出现

如果您发现自己不需要本地更改

使用git stash刷新本地更改,然后重试