Here you will find a minimal .gitignore for Arm Keil projects that you can use in Git. This file is created according to the following documentation (see page 3): https://www.keil.com/appnotes/files/apnt_279.pdf
Feel free to modify it and use it in your projects. There are also other examples of .gitignore files for Arm Keil projects (e.g. https://github.com/mrshrdlu/gitignore-keil)