Do i run git init in the src folder or in the project folder of my workspace? - eclipse

I couldn't find a question that similar to mine but the point I'm asking is where do I run git init? Do I run it in the src folder where my code is or in the project folder which contain the src folder and a bin folder? I'm working with eclipse and gitBash. Hope this is enough info.

What do you mean by builded project? Are you referring to .classpath, .project, .settings
When you create a repo, you need to include anything needed to actually build the project.
That include the src/ folder, but also other configuration files.
Those can include the .project (if it has only relative paths, easily reused by others), and the .classpath: see ".classpath and .project - check into version control or not?".
The settings/ folder can also be included 5see "Which eclipse files belong under Version Control", but not the .metadata/ subfolder.
It even can include settings for other IDEs like IntelliJ IDEA, if other contributors are using that tool.
It would not include the bin/ folder, typically added in a .gitignore, because its content is regenerated on demand (built).

Run it in the Project folder.
src folder contains the code files mostly. But supporting resources may be included in the other folders. And you will need to add everything to git without which project may have problem running.

Related

ignoring the build folder in an eclipse project in git repo

I am using eclipse java as an editor and would like to use the .gitignore to exclude the build folder for the project. This is what I have currently written in my .gitignore. The syntax seems to be right; I used the git documentation but I may have interpreted it wrong.
#ignoring the files within the build folder
/build/
build/**
I'm using a brand new repo so I shouldn't have any problems with already logged files in the repo.
I am trying to get git to ignore the build folder in the project file using a .gitignore. The ignore file didn't work. What could be a solution?
The way the .gitignore is written, this file needs to be in the same subfolder as the build folder, the file being ignored.

Can a folder that is in a Git repo be imported into Eclipse if it is not part of a project?

There is a folder in a Git repo which holds a bunch of sql scripts but the folder is not part of any project. When I try to create a folder in Eclipse it seems to require that I specify an existing project for it to be a subfolder of. Is that always required or can a folder exist at the same level as the projects, with no project for it to be under?
Everything in an Eclipse workspace must be in a project. Folders cannot be at the same level as a project.

Merge the src folder in Eclipse

How can I merge the src folder in eclipse without showing the packages,into a single folder.
i
I decided that, as #C-Otto said if you don't need resources or tests then they can remove as source folders. And these are not packages.
To remove as source folders.
Goto:
Project->Properties->Build Path->Sources Tab and remove what you wish :)

gitignore for folder of eclipse projects

I am working following a set of java swing tutorials, each is an Eclipse project, keep them in a workspace. I init a git repository in the workspace folder (mac), and upload to github. When I download this folder in another computer (linux), the projects are not recognized as such, and opening/importing in Eclipse fails. Says: 'Folder not recognized as project'. What is the best way to handle a collection of projects in git?
If you want to have all of your Eclipse project data across your machines, you will have to add the following files/folders to Git:
.classpath
.project
.settings (folder)
Make sure that these are not ignored in either your local or globale .gitignore files.
Ignore things like the bin and target folders, since they contain the compiled classes and shouldn't be added to Git.
Regarding the failed import: as #nwinkler writes, Eclipse looks for the .project and .classpath files so you need to add them (and the .settings directory) to your git repository.
Regarding .gitignore, I typically put the workspace stuff there (and then do import existing projects in eclipse after cloning):
That is,
.metadata/.plugins
.metadata/.lock
.metadata/.log
and then for each project, the bin folder
project_dir/bin
and any other generated files

eclipse+bzr (Or: DVCS + IDE)

I have some projects on bzr code repositories shared with colleagues.
Problem is, I really want to switch to eclipse in some projects, but I don't want to pollute the repository with the unnecessary metadata eclipse creates in its Workspaces.
Any idea how to keep Eclipse's metadata outside my bzr repo?
Adam
If you know the names of the meta files created, you could put them into your .bzrignore file in your repository's directory.
See this part of the bzr docs
All the main metadata in eclipse are in the workspace.
You project, meaning:
your .project file
your .classpath file
your .settings directory
your source files
should all be located elsewhere, within your main project directory.
All those files (except the .class files generated by the compilation) should be versioned.
See "Do you keep your project files under version control?" for more, but also:
What to put under version control?
When working with Eclipse, should I add the workspace to the source control?