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.

  • Get out of a folder using Git Bash
  • Restore Merged Branch in Bitbucket Repo
  • Using GIT Bash, ERROR: Repository not found - fatal: Could not read from remote
  • Gerrit: Fixing commit without change-id in footer
  • svn:external in git
  • Tracking Gitolite (common) hooks in Git
  • 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.

  • Windows Git GUI over ssh?
  • Git: How to recover a file after a pull / failed auto merge?
  • Docker container unable to clone from github.com
  • List of all git commits?
  • How to include newline characters in git tag messages
  • Bitbucket different keys and accounts
  • 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 .gitignore.

    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.

    Git Baby is a git and github fan, let's start git clone.