.gitignore slash after wildcard changes exclude behaviour

If the .gitignore file looks like this:


then the directory adir will not be included. However, if I change it to:

  • eclipse : impossible to import git project
  • Git and client/server code separation
  • Output to file using GIT in .NET project.json file
  • how to control ownership of files auto-pushed to a git target repo by commit hooks?
  • How to fix branches of partial directory structure in SVN to Git migration
  • Xcode 6.0.1 crashes when merging 2 branches
  • */

    Now it works – all directories are ignored but adir. Why is that? What is the proper way of ignoring everything but some particular directories?

    Based on the answer, I changed it to:


    and it works. But is there any preferred way?

  • No stash found when using git stash branch
  • How to change the default target branch for merges in Gitlab
  • Accidentally committed dev database to Git
  • How do I undo this git configuration?
  • How to add a git repository as a shared dependency of another git repository?
  • How to pull changes from the remote repository without pushing the local changes with Github Desktop
  • One Solution collect form web for “.gitignore slash after wildcard changes exclude behaviour”

    This is because when you wrote *, git understood “ignore every files”.

    Git doesn’t version folders, only files, so it saw adir/ as an empty directory.

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