简体   繁体   English

Git如何忽略未跟踪的CDT文件

[英]Git how to ignore untracked CDT files

I'm working on a C++ project, after imported this project to eclipse, there are 3 new files/folders generated, they are: 我正在研究一个C ++项目,将这个项目导入eclipse之后,生成了3个新文件/文件夹,它们是:

.cproject

.project

.settings/

Not every one is using eclipse, so I'm not allowed to push this files to the repository, but I need them in order to work on eclipse, what should I do in such a situation when do the pushing. 并非每个人都在使用eclipse,因此不允许将这些文件推送到存储库,但是我需要使用它们来处理eclipse,在这种情况下,当执行推送时我应该怎么做。

I installed the EGit plugin for eclipse found here: 我在这里安装了Eclipse的EGit插件:

http://www.eclipse.org/egit/ http://www.eclipse.org/egit/

In order to manage the hidden files in a C++ project I open the Navigator by selecting menu option: 为了管理C ++项目中的隐藏文件,我通过选择菜单选项打开Navigator

Window -> Show View -> Navigator . Window -> Show View -> Navigator

In the Navigator (on the left hand side) you can see all the files that are hidden from a C++ project (like .cproject ). Navigator (在左侧),您可以看到从C ++项目(例如.cproject )隐藏的所有文件。

Select all the files/folders you need to ignore, right-click on the selection and go to popup menu item: 选择所有需要忽略的文件/文件夹,右键单击所选内容,然后转到弹出菜单项:

Team -> Ignore . Team -> Ignore

When you first ignore files in a folder a new file may appear (if its not already there) called .gitignore . 当您第一次忽略文件夹中的文件时,可能会出现一个名为.gitignore的新文件(如果尚未存在)。 You need to decide if the .gitignore file is going to be shared project-wide or not. 您需要确定.gitignore文件是否将在项目范围内共享。 If it is not currently being tracked and it needs to be you can add it to the index by right-clicking it and selecting Team -> Add to index . 如果当前没有被跟踪,它需要你可以将其添加到index通过右键单击它并选择Team -> Add to index If it is not going to be tracked in the repository then you can select that file and ignore it. 如果不会在存储库中对其进行跟踪,则可以选择该文件并忽略它。

Hope that helps. 希望能有所帮助。

You could add rules to the .gitignore file (and push that change by itself) so that they won't appear in git's list of working directory changes when you are ready to stage files for a commit. 您可以将规则添加到.gitignore文件中(并自己推送更改),这样当您准备好要提交的文件时,它们就不会出现在git的工作目录更改列表中。

Git Ignore Documentation Git忽略文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM