git 如何在 IntelliJ IDEA 中将文件/文件夹添加到 .gitignore?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22585818/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 17:54:28  来源:igfitidea点击:

How to add files/folders to .gitignore in IntelliJ IDEA?

gitintellij-ideagitignore

提问by piotrek

I try to switch from Eclipse to IntelliJ IDEA. I have a project that uses Git and I want to quickly add files to .gitignorefile. In Eclipse I can right click on a file/directory and choose 'Add to .gitignore'.

我尝试从 Eclipse 切换到 IntelliJ IDEA。我有一个使用 Git 的项目,我想快速将文件添加到.gitignore文件。在 Eclipse 中,我可以右键单击文件/目录并选择“添加到 .gitignore”。

Is there anything like this in IntelliJ IDEA or I have to edit the file manually?

IntelliJ IDEA 中是否有类似的内容,或者我必须手动编辑文件?

回答by Rolf

IntelliJ has no option to click on a file and choose "Add to .gitignore" like Eclipse has.

IntelliJ 无法像 Eclipse 一样单击文件并选择“添加到 .gitignore”。

The quickest way to add a file or folder to .gitignorewithout typos is:

将文件或文件夹添加到.gitignore 且没有拼写错误的最快方法是:

  1. Right-click on the file in the project browser and choose "Copy Path" (or use the keyboard shortcut that is displayed there).
  2. Open the .gitignorefile in your project, and paste.
  3. Adjust the pasted line so that it is relative to the location of the .gitignorefile.
  1. 右键单击项目浏览器中的文件并选择“复制路径”(或使用显示在那里的键盘快捷键)。
  2. 打开项目中的.gitignore文件,然后粘贴。
  3. 调整粘贴的行,使其相对于.gitignore文件的位置。

Additional info: There is a .ignorepluginavailable for IntelliJ which adds a "Add to .gitignore" item to the popup menu when you right-click a file. It works like a charm.

附加信息:有一个可用于 IntelliJ的.ignore插件,当您右键单击文件时,它会在弹出菜单中添加一个“添加到 .gitignore”项目。它就像一个魅力。

回答by biniam

Intellij had .ignoreplugin to support this. https://plugins.jetbrains.com/plugin/7495?pr=idea

Intellij 有.ignore插件来支持这一点。 https://plugins.jetbrains.com/plugin/7495?pr=idea

After you install the plugin, you right click on the project and select new-> .ignore file-> .gitignore file (Git)enter image description here

安装插件后,右键单击项目并选择new-> .ignore file->.gitignore file (Git)在此处输入图片说明

Then, select the type of project you have to generate a template and click Generate. enter image description here

然后,选择您必须生成模板的项目类型并单击Generate在此处输入图片说明

回答by nanotexnik

You can create file .gitignore and then Idea will suggest you install plugin

您可以创建文件 .gitignore 然后 Idea 会建议您安装插件

回答by TechPassionate

Here is the screen print showing the options to ignore the file or folder after the installation of the .ignore plugin. The generated file name would be .gitignore enter image description here

这是屏幕打印,显示了在安装 .ignore 插件后忽略文件或文件夹的选项。生成的文件名将是 .gitignore 在此处输入图片说明

回答by mancini0

I'm using intelliJ 15 community edition and I'm able to right click a file and select 'add to .gitignore'

我正在使用 intelliJ 15 社区版,我可以右键单击一个文件并选择“添加到 .gitignore”

回答by Pavan

right click on the project create a file with name .ignore, then you can see that file opened.

右键单击项目创建一个名为 .ignore 的文件,然后您可以看到该文件已打开。

at the right top of the file you can see install plugins or else you can install using plugins(plugin name - .ignore).

在文件的右上角,您可以看到安装插件,否则您可以使用插件(插件名称 - .ignore)进行安装。

Now when ever you give a right click on the file or project you can see the option call add to .ignore

现在,当您右键单击文件或项目时,您可以看到选项调用添加到 .ignore