简体   繁体   中英

Forever exclude, ignore files in existing repo using git

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM