是否有可能跟踪.gitignore和未跟踪的.gitignore? [英] Is it possible to have a tracked .gitignore AND an untracked .gitignore?

查看:115
本文介绍了是否有可能跟踪.gitignore和未跟踪的.gitignore?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与其他人合作开发一个项目,并且在根目录下有一个.gitignore文件,它被提交给git。如果我想在根目录下创建一个新的文件或目录,我想让git忽略,但我不想将它放入公共.gitignore中,仅仅因为它仅适用于我。其中一个例子是,我经常在当前项目中创建一个沙箱目录,这样我就可以尝试某些命令的语法,同时仍然在项目中;不过,我无意与其他人分享。

解决方案

您可以使用 core.excludesfile为当前存储库设置额外的gitignore文件
$ g $ git config core.excludesfile .my_gitignore

然后将您的个人文件添加到此文件(以及 .my_gitignore 本身)。

I am collaborating on a project with others, and there is a .gitignore in the root directory which is committed to git. What if I wanted to make a new file or directory in root that I want git to ignore, but I don't want to put it in the public .gitignore, simply because it only pertains to me. One example of this is that I often create a "sandbox" directory in my current project so that I can experiment with syntax of certain commands while still being inside the project; however, I have no intention of sharing this with everyone else.

解决方案

You can set an additional gitignore file for the current repository with the core.excludesfile config option (as mentioned in the comments):

git config core.excludesfile .my_gitignore

And add your personal files to this file (as well as ".my_gitignore" itself).

这篇关于是否有可能跟踪.gitignore和未跟踪的.gitignore?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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