Lisa Anne
Lisa Anne

Reputation: 4595

Checkout error with working tree clean

Please, I get the error "Your local changes to the following files would be overwritten by checkout" but my working tree is clean.

does anyone have any idea of what is going on here?

$ 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

(the file app/build.gradle is not in my .gitignore file)


This is the top level .gitignore file:

### 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

This is a .gitignore file inside the /app directory (I don't know why it is there):

build

# Secrets
secrets.properties

Upvotes: 3

Views: 8244

Answers (3)

If anyone else wonders what's the next step after you notice that a file was added to assume unchanged with git ls-files -v | grep '^[[:lower:]]', you need to remove the flag with this command:

git update-index --no-assume-unchanged PATH/TO/THE/FILE.wtf

After that you can either git commit or git stash the changes and then you'll be able to git checkout

Upvotes: 0

LeGEC
LeGEC

Reputation: 51850

A wild shot :

I once read about a hidden "assume unchanged flag" (see this answer for example),
and the only way I know of for seeing if this flag is active on a file is (see this answer) :

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

What do you see when you run the above command on your repo ?

Upvotes: 4

sambhav sharma
sambhav sharma

Reputation: 5

do a git status see the files that are still to be added or changed.

This comes when there are local cahnges that can be overwritten

If you see that you dont need local changes

use git stash to flush local changes and try again

Upvotes: -2

Related Questions