Ignore git files locally but do not remove them from the repository
My team has is working on a git repository which contains a fully deployable WordPress app. This was configured in this way so that it could be deployed to a AWS stack quite easily. The repository contains a caching plugin which creates two folders in the wp-content/ folder named
When devs are checking out this application they are removing the caching features for development and thus the plugin is writing these changes to the two directories it uses. Which then encourages .git to stage them for a commit.
Is there anyway we can ignore these folders on dev machines but not remove them from the repo? Also i’d be interested in hearing other solutions which might help me get round this problem even if it is a larger change.
3 Solutions collect form web for “Ignore git files locally but do not remove them from the repository”
If you check out your repository and let
master follow that, then you can create a
devel branch where you just add cache w3tc-config to
I do something similar at work where I use git-svn to work with a svn repository which “links” in another svn repository for a sub module. Git clone did not fetch that sub module, so I just copied in the content from a svn checkout, checked into a devel branch (leaving master following the svn trunk branch), and added the sub module directory to .gitignore.
This is a solution that will require specific action from each developer, and not something you can push out from the repository. But similar to git hooks, if you create a
tools/do_it.sh script that does the required actions it is possible to lower the bar considerably.
You cannot have it both ways. Either the files are tracked or they are not. You cannot keep files in the repository but avoid tracking changes to them. Once they are tracked, it is up to you to not
git add them. (And it is worth noting that git does not track folders ever.)
Create an archive called
UnzipMeRightAfterCloning.zip that contains all the stuff you want ignored. Anyone cloning the repo needs to extract that archive, and it will add all the files/folders blocked by your
.gitignore settings. (And given your current setup, you will have to untrack the files in those folders first.)
Put these in your
.gitignore file. (Do not put in asterisk.)
Yes, create a local
.gitignore file in the project directory.
in the file paste the following
Now, these files will be excluded from git, but they won’t be removed from the repository.