Git - Switching Branches
Hello,
I want to switch branches. So I commit and push the current directory, but I still get a warning that changes would be lost.
From the console these appear to be the files causing the issue:
error: Your local changes to the following files would be overwritten by checkout:
.idea/workspace.xml
Please commit your changes or stash them before you switch branches.
error: Your local changes to the following files would be overwritten by checkout:
.gradle/2.13/taskArtifacts/cache.properties.lock
.gradle/2.13/taskArtifacts/fileHashes.bin
.gradle/2.13/taskArtifacts/fileSnapshots.bin
.gradle/2.13/taskArtifacts/taskArtifacts.bin
build/distributions/importer-1.0-SNAPSHOT.tar
build/distributions/importer-1.0-SNAPSHOT.zip
build/libs/importer-1.0-SNAPSHOT.jar
src/main/java/com/CmsExport.java
Please commit your changes or stash them before you switch branches.
Aborting
How to fix please?
请先登录再写评论。
To checkout a branch you need to remove conflicting files - so as recommended in the message Please commit your changes or stash them before you switch branches..
The reason for this seems to be that your repository has a lot of files that usually should not be tracked in VCS.E.g. .idea/workspace.xml - see https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems
Other files also seem to be a result of building the project, thus should not be tracked.
You could remove the unneeded files from git using git rm --cached command, and then commit.
Thanks for the prompt reply. I will try that.