My Keil projects often store a .username
file which I want to ignore using gitignore.
I thought I could do *.$(echo %username%)
in my .gitignore
, since echo %username
will print my name in the regular Windows prompt. I am using git bash, and appearently it cannot fetch these global variables (path, username, appdata etc).
How can I achieve my goal?
Thats not working then your
.gitignore
file is modified and you have to commit them.The best way is to save that files in a seperate ignored folder. you find a schema to exclude them. For example
But modifying your
.gitignore
is not the right way in that case i think.The patterns written in a
.gitignore
file are completely static, you can't use a language likeshell
to make advanced patterns.Instead, you could use an additional .gitignore file local to your copy of the repository:
This command tells git that there is an extra file in which it should look for file patterns to ignore (here, the file is named
.my_gitignore
).That is a local configuration, therefore, every user will have to issue the same command and create their
.my_gitignore
file by hand to add a static*.username
rule, but everyone will have their own (and only theirs).