Un-ignoring a file in an ignored directory in git

In my .gititnore I have an entry:


Which works well- the entire directory is ignored by git. Now, I just want to make an exception to this rule and keep this file /build/outputs/mapping/release/mapping.txt in git.

  • Why does git remember changes, but not let me stage them?
  • Run Grunt Build before OpenShift Build
  • Manage Keys with Puppet for puppet-vcsrepo
  • How to change the source of a Git subtree merge
  • Can EGit revert a merge commit?
  • git: how do I merge between branches while keeping some changesets exclusive to one branch?
  • How can I do this?

  • sharedRepository wrong group
  • Fixing published branch with wrong parent branch
  • Doesn't GIT force many big merges?
  • How to match dangling blobs with file names in Git?
  • Git: change HEAD commit's message without touching the index
  • Gitlab API for all projects under group
  • One Solution collect form web for “Un-ignoring a file in an ignored directory in git”

    The current rule for gitignore is

    It is not possible to re-include a file if a parent directory of that file is excluded.

    That means:

    • you need to ignore all the files recursively: that is ‘**
    • exclude all the folders recursively: those are ‘**/
    • exclude the file you want (which will work because its parent folder is not ignored as well)



    Check what is and is not ignored with git check-ignore -v (the -v is important):

    git check-ignore -v -- afile
    Git Baby is a git and github fan, let's start git clone.