dragonlinux
dragonlinux

Reputation: 3

How to ignore all files beside specific ones (which not to ignore)

We often use .gitignore to ignore files or folders.

How can I do the reverse things?

I just want to add specific files &r folders I interest in.

Upvotes: 0

Views: 53

Answers (1)

CodeWizard
CodeWizard

Reputation: 142552

You can do it like this:

Option 1:

  • Use the ! sign to "not ignore" the required patterns

    ### This is your git ignore file:
    
    # ignore all files and folders
    **/**
    
    # Add any specific required files
    !<file/path>
    

Option 2:

  • ignore all your files ad use the git add -f (force flag) to add any required tracked files

    ### This is your git ignore file:
    
    # ignore all files and folders
    **/**
    

    To add the desired files git add -f <file/path>

Upvotes: 1

Related Questions