gitignore my windows username

2019-07-18 03:01发布

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?

标签: git gitignore
2条回答
贼婆χ
2楼-- · 2019-07-18 03:22

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

/user/something/.*

But modifying your .gitignore is not the right way in that case i think.

查看更多
老娘就宠你
3楼-- · 2019-07-18 03:26

The patterns written in a .gitignore file are completely static, you can't use a language like shell to make advanced patterns.

Instead, you could use an additional .gitignore file local to your copy of the repository:

git config core.excludesfile .my_gitignore

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).

查看更多
登录 后发表回答