Git ignore deleted files

I have a website project that has more than 50,000 unimportant files (to development) in some directories.


The stuff in /files is already in the repo. I want to delete all the files in /files on my local copy but I want git to ignore it so it doesn’t delete them when I do a pull on the web server.

  • Unstage all deleted files in Git
  • Undo delete in GIT
  • What's the “proper” way to delete files from a ClearCase snapshot?
  • How do I completely nuke a file from a git repo?
  • Windows batch file to delete .svn files and folders
  • Remove a file from a Git repository without deleting it from the local filesystem
  • Any ideas?

  • How do I add/upgrade/downgrade a remote Git project in my repository without using submodules?
  • Merging 2 branches together in GIT
  • GitHub API - write to repo
  • Git: Set up a fetch-only remote?
  • Someone sent me a pull request, what do I do?
  • Quantifying the amount of change in a git diff?
  • 4 Solutions collect form web for “Git ignore deleted files”

    Ignoring a whole directory didn’t work. I had to do this:

    for i in `git status | grep deleted | awk '{print $3}'`; do git update-index --assume-unchanged $i; done

    The code below works on deleted as well as modified files to ignore it when you do a git status.

     git update-index --assume-unchanged dir-im-removing/

    or a specific file

    git update-index --assume-unchanged config/database.yml

    Ignore modified (but not committed) files in git?

    Beware: The suggestion above for deleted files when you do a “git commit -am ” includes the deleted file!

    A solution that would work for me is to instead of deleting the file, just make it’s content blank. This is what I used to mute a .htaccess file.

    Creating a sub-repo is one solution, but you should make that sub-repo a submodule.

    That way:

    • you keep a link between your normal content and that ‘files’ content
    • if the ‘files’ content evolves one day, you can register its evolution in the main repo
    • you can checkout your main repo without ” git submodule update ” (that is without filling the ‘files‘ content
    • on deployment, a git submodule update after the git submodule init will be enough to get back the right version of the ‘files‘ content.

    Ok Ive found a solution. Simply create a new repo in the sub directories and the parent repo will ignore them.

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