-1

I have 5 files that I want to ignore in git on my test server. I updated my git ignore file to include them but I still get an error saying "You local changes to the following files would be overwritten by checkout" and am unable to proceed with the checkout. I am on the server and see the .gitignore file as been updated. The error lists the problematic files under the error message:

path\to\file_a
path\to\file_b
path\to\file_c
path\to\file_d
path\to\file_e

My .gitignore file looks like the below:

# Directories #
###############
# Ignore everything:
/*

# Except for the web, database, and company web directories:
!web/
!database/
!cron/
!includes/
!.gitignore

# But still ignore these directories and files:
path/to/file_a
path/to/file_b
path/to/file_c
path/to/file_d
path/to/file_e

I believe I should not get the git error because I have listed the files in the .gitignore

I did the rm --cahced path\to\file method and that did not work enter image description here

SJW525
  • 51
  • 1
  • 9
  • 2
    Possible duplicate of [How to stop tracking and ignore changes to a file in Git?](https://stackoverflow.com/questions/936249/how-to-stop-tracking-and-ignore-changes-to-a-file-in-git) – melpomene Dec 02 '18 at 17:30

1 Answers1

0

.gitignroe doesn't apply to files that are tracked in git. In addition to adding them to .gitignore, you need to remove these files from git's tracking by using git rm --cached.
(note: the --cached flag removes the files from git's tracking but preserves them in the working directory, so you don't lose your local changes)

$ git rm --cached path/to/file_a path/to/file_b path/to/file_c path/to/file_d path/to/file_e
Mureinik
  • 297,002
  • 52
  • 306
  • 350