gitignore我的Windows用户名 [英] gitignore my windows username

查看:167
本文介绍了gitignore我的Windows用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

My Keil项目经常存储一个 .username 文件,我想用gitignore忽略它。

我认为我可以在中执行 *。$(echo%username%) .gitignore ,因为 echo%username 会在常规的Windows提示符下打印我的名字。我使用git bash,并且显然它不能获取这些全局变量(路径,用户名,appdata等)。



我怎样才能达到目标?

解决方案

写在 .gitignore 文件中的模式是完全静态的,你不能使用像 shell 这样的语言来创建高级模式。



相反,你可以使用一个额外的.gitignore文件本地您的版本库

  git config core.excludesfile .my_gitignore 

这个命令告诉git有一个额外的文件,它应该查找要忽略的文件模式(这里的文件名为)。

这是一个本地配置,因此,每个用户都必须发出相同的命令并创建它们的 .my_gitignore 手动添加静态 *。username 规则,但是每个人都有自己的(并且只有他们自己的) 。


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?

解决方案

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

这篇关于gitignore我的Windows用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆