Negation selector of . gitignore not working

Asked

Viewed 38 times

0

I have a repository where I put exercises done in C, when compiled, generate an executable without extension (on Linux, on Windows generates a file ".exe"). I just want the files with extension to appear .c in folders, however it also ignores any file .c

Man .gitignore is like this:

    /*

    !/*.c

    *.exe
  • 1

    did not understand your question. Please explain better. This is happening when uploading files to a remote Git repository? ( git push )

1 answer

0


Your file .gitignore is working as you wish in the repository root directory. However, if the desired files are inside sub-folders, you should add these sub-folders also in a denial of the .gitignore.

Try the following:

*
!*/
!*.c

Which gives the following result:

$ ls pastanova/
abacate.c  abacate.exe*  b.c  b.exe*

$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   a.c
        new file:   pastanova/b.c

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        pastanova/abacate.c

That is the desired result. For more information see this question (in English).

Note: Your last line *.exe was redundant.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.