gitignore my windows username

 ̄綄美尐妖づ 提交于 2019-12-11 02:24:36

问题


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?


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/26670878/gitignore-my-windows-username

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!