0

I would like to ignore some particular files from committing bundle, so included them into project's ".gitignore" file:

MDK-ARM/test1_prj/
!MDK-ARM/test1_prj/*.hex
!MDK-ARM/test1_prj/*.axf
MDK-ARM/JLinkLog.txt

But unfortunately, the last line doesn't work, and consistently included in commits, can't explain why.

Another question is how to ignore changing .gitignore itself (except hiding 'em)

PS: Briefly saying I want to exclude all compiling and debugging junk except the resulting files.

Frant
  • 5,382
  • 1
  • 16
  • 22
Valio
  • 31
  • 9
  • “consistently included in commits” That is correct behaviour. If a file has been included in a commit, it keeps on being included, and _.gitignore_ has no effect on it. – matt Oct 04 '20 at 14:04

1 Answers1

1

First, make sure the file is not already tracked:

git rm --cached -- MDK-ARM/JLinkLog.txt

Second, if a folder is ignored, all the other rules regarding files inside that folder won't matter.
It is not possible to re-include a file if a parent directory of that file is excluded.

You need to blocklist files, not folders, before grantlisting exceptions.

MDK-ARM/test1_prj/**
!MDK-ARM/test1_prj/**/
!MDK-ARM/test1_prj/*.hex
!MDK-ARM/test1_prj/*.axf

Finally, check those rules do apply with:

git check-ignore -v -- MDK-ARM/test1_prj/a_File_Which_Should_Be_Ignored

If it is ignopred, you will see the .gitignore file involved, and its ignore rule line number.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250