Sathish Manohar
Sathish Manohar

Reputation: 6119

How to ignore all files, but not directories in Git

I want to ignore all the files present in current directory, but want to track all the directories and sub directories.

How can I do that?

Adding * in .gitignore simply ignores everything, including directories and sub-directories. How to ignore only files, but not directories.

Upvotes: 1

Views: 98

Answers (2)

Josh Lee
Josh Lee

Reputation: 177510

# Ignore everything in this directory
/*
# Except for directories
!/*/

Upvotes: 1

Adam Dymitruk
Adam Dymitruk

Reputation: 129526

you should be able to add an exclude section below with */*

Upvotes: 0

Related Questions