0

I'm working on a C++ project, after imported this project to eclipse, there are 3 new files/folders generated, they are:

.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.

Tom
  • 385
  • 3
  • 7
  • 17
  • 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. ([Git ignore documentation](http://git-scm.com/docs/gitignore)) – Cody Stott Oct 03 '14 at 15:38
  • Glad it worked. I re-posted that as an answer. – Cody Stott Oct 03 '14 at 19:08

2 Answers2

0

I installed the EGit plugin for eclipse found here:

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

In order to manage the hidden files in a C++ project I open the Navigator by selecting menu option:

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).

Select all the files/folders you need to ignore, right-click on the selection and go to popup menu item:

Team -> Ignore.

When you first ignore files in a folder a new file may appear (if its not already there) called .gitignore. You need to decide if the .gitignore file is going to be shared project-wide or not. 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. If it is not going to be tracked in the repository then you can select that file and ignore it.

Hope that helps.

Galik
  • 47,303
  • 4
  • 80
  • 117
  • Is that usage for the Git Eclipse interface? Also, if he ignores the **.gitignore** file, won't he get a merge conflict when he pulls if someone else pushes a **.gitignore** file they create for the same repository? – Cody Stott Oct 03 '14 at 15:57
  • @CodyStott Its using EGit the git plugin for eclipse. Also I assume the `.gitignore` file is not in the repository (it should not be) because if it was he would not need to ignore the files himself, he would have pulled the rules when he pulled the `.gitignore` file. – Galik Oct 03 '14 at 16:13
  • `.gitignore` is committed. An alternative is to use another file and setup `core.exludesfile` with `git config`. See [gitignore(5)](http://git-scm.com/docs/gitignore). – musiKk Oct 03 '14 at 16:13
  • @Galik he mentions that _he_ imported the project to Eclipse. So there wasn't a need for the ignore rules until he did this. That doesn't mean someone else won't commit their **.gitignore** file in the future though. I just think it's hazardous to have a workflow where you can potentially conflict when you pull. – Cody Stott Oct 03 '14 at 16:18
  • @CodyStott That's the reason I suggest the .gitignore file should not be committed. Every developer has different files they need to ignore. – Galik Oct 03 '14 at 16:22
  • @Galik I'm pretty sure for the most part, every developer will be generally ignoring the same files. http://stackoverflow.com/questions/767147/ignore-the-gitignore-file-itself – Cody Stott Oct 03 '14 at 17:39
  • Hi, thank you for your help, I solved this with adding rule to the `.gitignore` file. – Tom Oct 03 '14 at 19:03
0

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.

Git Ignore Documentation

Cody Stott
  • 484
  • 1
  • 7
  • 19