我应该将git存储库存储在Home或Eclipse Workspace中吗? [英] Should I store git repository in Home or Eclipse Workspace?
问题描述
我刚刚从svn转到git,并热衷于打好基础。
I'm just moving from svn to git, and am keen to lay some good foundations.
默认情况下,Eclipse希望将我的本地克隆库存储在〜/饭桶。我保持在同一个工作空间中保存所有数据,所以我倾向于将其保留在我的工作区。
By default Eclipse wants to store my local clone repository in ~/git. I'm more comfortable keeping all data for a task in the same workspace - so I'm inclined to keep it in my workspace.
有什么重要的利弊我应该考虑一下?
Are there any significant pros/cons I should consider?
我不打算做很多分支 - 我真的要下去dvcs路由,主要是为了克服一些不可靠的互联网通信问题。 p>
I don't intend doing a lot of branching - I'm really going down the dvcs route mostly to overcome some unreliable internet comms issues.
推荐答案
我也在Eclipse中切换到Git,并阅读有关此问题。看来,目前的智慧(尽管不是每个人都同意)是:
I'm too switching to Git in Eclipse, and reading about this issue. It seems that current wisdom (though not everyone agrees) is:
-
用于不让你的项目在工作区目录下面。
Get used to NOT having your projects below the workspace directory.
每个都有一个git仓库一组相关的eclipse项目(当然也许更多的文件)。 相关项目的概念取决于您的方便性[*]
Have one git repository for each group of related eclipse projects (and perhaps more files, of course). The concept of "related projects" is up to your convenience [*]
对于每个存储库,每个Java项目都有一个第一级目录。这意味着您将有一个 .git /
目录,并在同一级别,项目目录。
For each repository, one first level directory for each Java project. This implies that you'll have a .git/
directory, and, at the same level, the project directories.
示例:假设在GIT之前,你有一个eclipse工作区有几个项目:
Example: suppose that, "before GIT", you had one eclipse workspace with several projects:
/wk/workspace/.metadata/
/wk/workspace/projXXX/
/wk/workspace/projXXXtest/ (related with the previous)
/wk/workspace/projYYY1/ |
/wk/workspace/projYYY2/ > three related projects
/wk/workspace/projYYY3/ |
/wk/workspace/projZ/ (a project you are not going to version in git)
然后您将创建两个空目录,每个存储库一个,说:
Then you'll create two empty directories, one for each repository, say:
~/repositories/XXX/
~/repositories/YYY/
然后,使用新的GIT布局,您将:
and afterwards, with the new GIT layout, you'll have:
/wk/workspace/.metadata/
/wk/workspace/projZ/
~/repositories/XXX/.git/ (XXX related repository - non-bare)
~/repositories/XXX/projXXX/
~/repositories/XXX/projXXXtest/
~/repositories/YYY/.git/ (YYY related repository - non-bare)
~/repositories/YYY/projYYY1/
~/repositories/YYY/projYYY2/
~/repositories/YYY/projYYY3/
Eclipse(EGit)为您点击 Team-> Share 在现有项目中,并指定(在示例中)〜/ repositories / XXX / .git /
作为存储库,(〜/库/ XXX /
作为工作目录,将存储库内的路径空白)。
Eclipse (EGit) does all this for you when you click Team->Share over an existing project and specify (in the example) ~/repositories/XXX/.git/
as repository, (~/repositories/XXX/
as "Working directory", leave "Path within repository" blank).
[*]在这里,每个项目组都是从Git的角度来看,只是存储库中的一组目录。一些相关的含义:在上面的例子中,您将永远不会在Eclipse工作区中有两个不同的分支/版本的项目 projYYY1
- projYYY2
同时;而且,当您标记项目提交时,您实际上标记了完整的存储库(项目组)提交。
[*] Bear in mind that here each group of projects is, from the Git point-of-view, just a set of directories inside a repository. Some relevant implications: in the above example, you'll never have in the Eclipse workspace two different branches/versions of projects projYYY1
-projYYY2
simultaneously; and, say, when you tag a project commit, you are actually tagging the full repository (group of projects) commit.
这篇关于我应该将git存储库存储在Home或Eclipse Workspace中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!