Forever exclude, ignore files in existing repo using git

162 views Asked by At

I'm working with a large PHP project in git and having trouble with my working copy because of a couple files, including the .htaccess, .gitignore and database configuration files getting overwritten or wanting to be staged/committed.

The problem I'm running into is that every time I try to switch branches, I'm bothered to either stash my changes or told that I can't merge because files are not uptodate. I've tried updating my exclude to the following:

.htaccess
.gitignore
./application/config/vagrant/config.php
./application/config/vagrant/database.php

Along with this, I've also tried to set these files to assume-unchanged - which is where i get the issues trying to switch branches and it telling me the files are not uptodate.

What I'd like to happen is for those files to be completely ignored forever. Whenever I switch branches, I don't want them to be merged, I just want them to essentially be removed from the repo without affecting any of the other users that work on the project.

1

There are 1 answers

0
jub0bs On BEST ANSWER

From your description of the problem, it seems that the offending files

.htaccess
.gitignore
./application/config/vagrant/config.php
./application/config/vagrant/database.php

are already being tracked; perhaps you or one of your collaborators started tracking them by mistake a long time ago...

If you want Git to be able to ignore those files, you first need to tell Git to stop tracking them by running

git rm --cached <paths>

Then, and after adding appropriate entries in your .gitignore file, you'll be able to ignore those files, as desired.