astropanic
astropanic

Reputation: 10939

Git: tracking only selected entries

I have a directory, in this directory I have many subdirectories. I want to track only 4 of them (I know they names).

Many people have access to the top directory, and some of them, sometimes are adding new subdirectories.

When I now list the status of the repo with the command

git status

I get a huge list of 'untracked' entries

How I can tell git, I'm only interested in the four directories I want to track ?

Upvotes: 0

Views: 491

Answers (2)

Chris Johnsen
Chris Johnsen

Reputation: 224689

.gitignore in the top level directory (or .git/info/excludes):

*
!/somedir_a/
!/another_dir/
!/dir.the.third/
!/one-last-dir/

But if multiple people have access to the top-level directory, they could damage your .git dir.

Alternatively, you could just run git status -uno (means “do not show untracked files”). Use git config status.showUntrackedFiles no to make git status work like this by default in that repository.

Upvotes: 3

Vagaus
Vagaus

Reputation: 4215

Wouldn't adding the entries you don't want to track in a .gitignore file work?

Best

Upvotes: 0

Related Questions