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:
.gitatributes
.gitignore
README.MD
code snippets (folder which contains the individual projects)
* 00. Blink
* 01. Buttons
* …
* etc

The content of of my .gitignore file is:
**/.pioenvs
**/.pio
**/.piolibdeps
**/.gitignore
**/test
**/.travis.yml
**/.vscode/extensions.json
**/.vscode/settings.json
*/.vscode/.browse.c_cpp.db
**/.vscode/c_cpp_properties.json
**/.vscode/launch.json
**/.vscode/extensions.json
**/include/README
**/lib/README

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:
!/.pioenvs/*/firmware.bin
!
/.pioenvs//firmware.bin
!/
/.pioenvs//firmware.bin
!/
/.pioenvs/*/firmware.bin

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 stackoverflow.com 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.
2 Likes

Created the topic at stackoverflow : https://stackoverflow.com/questions/54680388/force-including-files-in-gitignore-if-location-is-not-known

Who knows, maybe it will help.