我应该把 .gitignore 放在哪里才能影响所有项目?

发布于 2025-01-08 01:59:01 字数 130 浏览 3 评论 0原文

我应该在哪里放置 .gitignore 文件,以便我的所有项目都使用这些设置?

我尝试了各种文件夹,只有将其放入项目文件夹中才能使其正常工作,但是设置(当然)仅应用于该项目......而不是我的其他项目。

where should I place a .gitignore file so that all my projects use those settings?

I tried various folders and I can only get it to work if I put it in my project folder, but then the settings (of course) only are applied to that project... not my other projects.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

最偏执的依靠 2025-01-15 01:59:01

git 包含一个“全局”配置选项,可以告诉它在启动项目时包含您想要始终忽略的文件。例如,如果你的忽略文件的编译被称为:ignore_global,你可以这样做;

git config --global core.excludesfile /path/to/your/ignore_global

有关更多信息,请访问:忽略文件

git include a "global" configuration option which can tell it to include the files you want to ignore always when you start a project. Example, if the compilation of your ignore files is called: ignore_global, you could do this;

git config --global core.excludesfile /path/to/your/ignore_global

more about it at here: Ignore Files

擦肩而过的背影 2025-01-15 01:59:01

即使以前的解决方案有效,我还是建议使用全局 ~/.gitignore_global 并使用以下命令将其添加到排除文件中:

git config --global core.excludesfile ~/.gitignore_global

这是 github 推荐的解决方案: https://help.github.com/articles/ignoring-文件/

Even though the previous solutions work, I would recommend having a global ~/.gitignore_global and adding it to your exclude files with the command:

git config --global core.excludesfile ~/.gitignore_global.

This is the recommended solution by github: https://help.github.com/articles/ignoring-files/

合久必婚 2025-01-15 01:59:01

您需要使用命令行。原因是,您需要将 gitignore 文件放置在 Eclipse 项目的父目录中,但您无法在 Eclipse 工作台中看到该目录(因为 Eclipse 项目是那里的顶级实体)。

例如,您有 2 个 Eclipse 项目,它们像这样存储在存储库

\mygitrepo\project1

\mygitrepo\project2

中,然后只需在 mygitrepo 目录中添加 .gitignore 文件即可。

You need to use the command line. The reason is, that you need to place the gitignore file in the parent directory of your Eclipse projects, but you cannot see that directory in the Eclipse workbench (as Eclipse projects are top level entities there).

E.g. you have 2 Eclipse projects, which are stored like this in your repository

\mygitrepo\project1

\mygitrepo\project2

then just add the .gitignore file in the mygitrepo directory.

小嗷兮 2025-01-15 01:59:01

它不是特定于 Eclipse 的。试试这个: http://programblings.com/2008/10/22/git -全局忽略/

It is not eclipse specific. Try this: http://programblings.com/2008/10/22/git-global-ignores/

千纸鹤带着心事 2025-01-15 01:59:01

无需使用命令行。

  1. 打开 Window->Preferences
  2. 选择 Team->Git-Configuration
  3. 切换到 User Settings 选项卡。
  4. 单击 Add Entry ... 并输入 core.excludesfile 作为键,输入 ~/.gitignore 作为值
  5. Open ~/.gitignore< /code> 并在 .gitignore 中添加所有要忽略的模式,

即:

target
.*
  1. 重新启动 eclipse

No need to use the commandline.

  1. Open Window->Preferences
  2. Select Team->Git-Configuration
  3. Switch to User Settings tab.
  4. Click Add Entry ... and enter core.excludesfile as key and ~/.gitignore as value
  5. Open ~/.gitignore and add all your to-ignore-patterns inside the .gitignore

I.e:

target
.*
  1. Restart eclipse
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文