git 我可以制作用户特定的 gitignore 文件吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5724455/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can I make a user-specific gitignore file?
提问by asdsadasds
I want to change the gitignore, but not everyone on the team wants these changes. How can a user have their own specific git ignore file?
我想更改 gitignore,但并不是团队中的每个人都想要这些更改。用户如何拥有自己的特定 git ignore 文件?
采纳答案by grzuy
For user-specific and repo-specific file ignoring you should populate the following file:
对于特定于用户和特定于存储库的文件忽略,您应该填充以下文件:
$GIT_DIR/info/exclude
Usually $GIT_DIR stands for:
通常 $GIT_DIR 代表:
your_repo_path/.git/
回答by Dave Kincaid
You can create your own .gitignore using
您可以使用创建自己的 .gitignore
git config --global core.excludesfile $HOME/.gitignore
Then put your desired entries in that file.
然后将所需的条目放入该文件中。
回答by Rafe Kettler
In their .gitconfig:
在他们的 .gitconfig 中:
[core]
excludesfile = ~/.global_gitignore
That way, they can ignore certain types of files globally. Each user can have their own global ignore file.
这样,他们就可以全局忽略某些类型的文件。每个用户都可以拥有自己的全局忽略文件。
回答by Sergey Zhigalov
For example, you want ignore ~/some/path/.idea
folder:
例如,您要忽略~/some/path/.idea
文件夹:
# 1. Add .idea to user specific gitignore file
echo .idea > ~/.gitignore
# 2. Add gitignore file to gitconfig
git config --global core.excludesfile ~/.gitignore
回答by obscure18
As indicated in Atlassian's .gitignore tutorial, you could also use your repo's <repo>/.git/info/exclude
file that you can easily edit with any text editor. It works the same as .gitignore
.
正如Atlassian 的 .gitignore 教程中所指出的,您还可以使用您的 repo<repo>/.git/info/exclude
文件,您可以使用任何文本编辑器轻松编辑该文件。它的工作原理与.gitignore
.
I could easily ignore my intelliJ files, personal dockerfiles and stuff only I need to work with.
我可以很容易地忽略我的 intelliJ 文件、个人 dockerfiles 和我需要使用的东西。