Tim Bezhashvyly
Tim Bezhashvyly

Reputation: 9100

How to include only selected files into git repository and exclude all the rest?

Is there any chance to do an opposite to what .gitignore file does? I mean include only specified files and exclude all the rest? Thank you in advance.

Upvotes: 9

Views: 3899

Answers (2)

Viet Anh Do
Viet Anh Do

Reputation: 489

if you want to concern only one folder in root try this:

# ignore everything
*
# except .gitignore file
!.gitignore
# except my folder
!concered_folder_name
!concered_folder_name/*

Upvotes: -2

CharlesB
CharlesB

Reputation: 90316

You can try the following:

#ignore everything
*

#except .c source
!*.c

(! negates the patterns specified in gitignore)

Upvotes: 13

Related Questions