Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
603 views
in Technique[技术] by (71.8m points)

git - 如何配置git在本地忽略某些文件?(How do I configure git to ignore some files locally?)

Can I ignore files locally without polluting the global git config for everyone else?

(我可以在本地忽略文件而不污染其他所有人的全局git配置吗?)

I have untracked files that are spam in my git status but I don't want to commit git config changes for every single little random untracked file I have in my local branches.

(我有处于git状态的垃圾邮件的未跟踪文件,但我不想为我在本地分支机构中拥有的每个单个随机未跟踪文件提交git config更改。)

  ask by Bjorn translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the relevant Git documentation :

(从相关的Git文档中 :)

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (eg, auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.

(特定于特定存储库但不需要与其他相关存储库共享的模式(例如,位于存储库内但特定于一个用户工作流程的辅助文件)应放入$GIT_DIR/info/exclude文件。)

The .git/info/exclude file has the same format as any .gitignore file.

(.git/info/exclude文件与任何.gitignore文件具有相同的格式。)

Another option is to set core.excludesFile to the name of a file containing global patterns.

(另一个选项是将core.excludesFile设置为包含全局模式的文件的名称。)

Note, if you already have unstaged changes you must run the following after editing your ignore-patterns:

(请注意,如果您已经取消暂存更改,则必须在编辑忽略模式之后运行以下命令:)

git update-index --assume-unchanged [<file>...]

Note on $GIT_DIR : This is a notation used all over the git manual simply to indicate the path to the git repository.

(注意在$GIT_DIR :这是一个符号使用遍布 git的手册只是为了表明路径git仓库。)

If the environment variable is set, then it will override the location of whichever repo you're in, which probably isn't what you want.

(如果设置了环境变量,那么它将覆盖您所在的任何存储库的位置,而这可能不是您想要的。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...