Using .gitignore to keep firmware files

Hello everyone!

I want to create a github repository where I’ll be collecting code snippets with extra comments. The problem becomes in keeping firmware files with .gitignore file.

The repository folder structure is:
code snippets (folder which contains the individual projects)
* 00. Blink
* 01. Buttons
* …
* etc

The content of of my .gitignore file is:

The compiled firmware is created as “firmware.bin” file in subfolder (subfolder has a name of used dev-board) of .pioenvs folder. How to keep it?
I tried several options:

No reseults. Is there a way to keep the firmware file?

It seems like your question is about .gitignore files and you might get a better response on as a general question. Refer e.g. to git - .gitignore exclude folder but include specific subfolder - Stack Overflow.

I’ve seen that post. The problem is that approach requires the “guaranteed location” of file with all subfolder.
In my case there will be always 2 variables:

  • project name
  • devboard name

Looks like .gitignore doesn’t work with any unknown parts (
Still looking for a solution.

  1. stackoverflow can help you better with this
  2. a cheap way to circumvent the problem is to add a Python extra script which copies the produced firmware back to the main folder, see docs lines env.AddPostAction("buildprog", callback...) and related.

Created the topic at stackoverflow :

Who knows, maybe it will help.