How to keep .git folder out of a Cloned Eclipse Project
Asked Answered
V

2

2

Issue
After importing an Eclipse project from a cloned git repository, I make some changes and commit - and wtf? I get a ".git" folder added to the project, the whole shebang with the heads and refs and worst of all the whole object database gets added to the project, all files/folders having that little question-mark icon signaling that the files have not been added / are not yet tracked by git. This .git folder exists in the actual Working Directory (how does that even make sense?). You can imagine what an annoyance this causes when trying to use the "Synchronize" tool/view (which is supposed to make life easier for committing, you can see all the changes and changed files and diffs).

Question (tl;dr)
How to correctly import an Eclipse project from a cloned git repository? I don't want a .git folder showing up in "Team > Synchronize" when I commit, let the .git folder reside somewhere else outside of my project.

Additional Info
I'm on Windows 7 using Eclipse Indigo and Egit. I am using Egit to clone a git repo from http://git.apache.org/ (the ofbiz project, to be exact) and in the wizard I choose the option to import an existing project from this newly cloned repo.
Yes I am aware of how little I may expect from Egit. In fact, if there are any alternative ways (external git tool? command line git for windows? other?) to use a git-tracked project in Eclipse which keeps the actual .git stuff out of the project, i'd gladly abandon Egit.

Vermiculate answered 31/8, 2011 at 15:11 Comment(0)
K
0

When you clone a git repository, the default behavior is to create a .git folder inside the root of the local clone. You can change the default behavior by setting the GIT_DIR variable:

Git docs says:

"GIT_DIR If the GIT_DIR environment variable is set then it specifies a path to use instead of the default .git for the base of the repository."

Depending on which terminal you use, you could set it using setenv or export. For example in a bash terminal:

export GIT_DIR='[path_to_git_directory]'

After setting the variable, you should be able to clone and the .git directory should show up at the specified directory.

Khabarovsk answered 3/9, 2011 at 3:0 Comment(0)
S
0

I totally agree - I can't imagine it would ever be anyones intent to commit the .git folder!

And git/EGit knows that this is the repository folder of the project, so it should be easy to implement the appropriate exception - so that this folder does not become part of the synchronization.

I know the following does not solve your problem, but in cases where you control the way files are layed out in the repository, you could choose to have the Eclipse project folder not be the root folder of the repository, but rather a sub-folder.

This also allows you to have stuff in the repository that should not show up in Eclipse, or even have multiple Eclipse projects grouped in one repository (if you should wish to do so).

Staw answered 17/11, 2011 at 20:40 Comment(1)
EGit does indeed supply a check-box offering the option of placing the git repo outside the project (I think), but it also gives scary warnings about doing this... If you try it you'd see what I'm talking aboutVermiculate

© 2022 - 2024 — McMap. All rights reserved.