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

喜欢而已 提交于 2019-12-06 05:11:53

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!