将Git存储库保存在Eclipse工作区内或外部是否更好? [英] Is it better to keep Git repository inside or outside of Eclipse workspace?

查看:1601
本文介绍了将Git存储库保存在Eclipse工作区内或外部是否更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个典型的Eclipse / Subversion用户,开始迁移到Git。我研究了git的基本概念,并决定坚持一个项目,每个存储库方法最初是为了保持简单。我仍然有困难,但决定在哪里放置每个项目的存储库。

I am a typical Eclipse/Subversion user beginning the migration to Git. I've researched the basic concepts of git and have decided to stick to a one project per repository approach initially to keep things simple. I am still having trouble, though, deciding where to place the repository for each project.

我花了很多时间查看这个问题,虽然我相信该问题的作者假设您只能使用Eclipse来管理存储库,如果存储库位于在Eclipse工作空间中,这当然不是真的。

I have spent a lot of time reviewing the answers to this question, although I believe the author of that question was assuming that you can only use Eclipse to manage the repository if the repository is located within the Eclipse workspace, which is, of course, not true.

尽管如此,最令我震惊的是,除了一个答案包括接受的答案)建议将资源库保存在Eclipse工作区内,而只有一个答案指出, EGit用户指南建议完全相反。

The thing that struck me most about that question, though, was the fact that all but one answer (including the accepted answer) suggested keeping the repository inside the Eclipse workspace, whereas only one answer pointed out that the EGit User Guide recommends the exact opposite.

然而,实际上会出现一些实现方式由Eclipse / EGit引发,其中一些似乎与EGit的建议相矛盾。

It would appear in practice, however, that there are a number of approaches implemented by Eclipse/EGit, some of which seem to contradict the EGit recommendations.

例如,如果您使用新建项目向导从Git创建新的PHP项目,存储库是远程的,Eclipse / EGit将高兴地在Eclipse工作区中创建一个项目文件夹,并将存储库(.git)放在项目文件夹中。这是我实际想要的最终结果,因为它将所有内容都封装在Eclipse工作区中。

For example, if you use the New Project Wizard to create a New PHP Project from Git and the repository is remote, Eclipse/EGit will happily create a project folder in the Eclipse workspace and put the repository (.git) in the project folder. This is the end result that I actually want, as it keeps everything encapsulated within the Eclipse workspace.

但是,如果您使用新建项目向导并选择Git存储库是本地的,Eclipse / EGit不会像远程存储库那样克隆存储库。相反,它使用该存储库的工作副本作为项目位置,在该位置创建其.project和其他元数据,并在与该项目名称相同的工作副本中创建一个新的(看似不必要的)文件夹(所以你结束例如,〜/ git / blah / blah )。如果删除该多余的文件夹,最终会出现与第一个示例相同的结构,唯一的区别是项目文件夹不是Eclipse工作空间文件夹的子文件夹,它位于文件系统的其他位置(例如。〜/ git / blah )。这种方法似乎是唯一的积极因素是它遵守EGit用户指南中的建议,但从技术角度来看,很难看出这与第一个例子是如何不同的。

However, if you use the New Project Wizard and select a Git repository that is local, Eclipse/EGit doesn't clone the repository like it does for remote repositories. Instead it uses the working copy of that repository as the project location, creates its .project and other meta stuff in that location and also creates a new (seemingly unnecessary) folder within that working copy with the same name as your project (so you end up with, for example, ~/git/blah/blah). If you delete that superfluous folder you end up with a structure that is identical to the first example, the only difference being that the project folder is not a sub-folder of your Eclipse workspace folder, it is somewhere else on your file system (eg. ~/git/blah). The only positive thing this approach seems to have going for it is that it adheres to the recommendations in the EGit User Guide, but from a technical perspective, its hard to see how this is really all that different to the first example.

鉴于这些令人费解的观察结果,我想知道人们使用这些方法有哪些体验,如果忽略EGit用户指南中的建议,那么陷阱可能是什么。

Given these puzzling observations, I'm wondering what sort of experiences people have had using each of these approaches and what the pitfalls might be if one ignores the recommendations in the EGit User Guide.

推荐答案

两种解决方案的含义直接列在您链接的用户指南中。我可以告诉你,这个部分

The implications of both solutions are listed directly in the user guide that you linked. I can tell you that the part


这可能会导致性能问题

This can result in performance issues

不幸的是非常真实。因此,如果您的工作空间中有一个git目录中有大量文件,许多git操作将以一个计数对象...对话框开始,阻止您的IDE,因为它会扫描工作区中的所有文件。对于我目前的20000个文件,这意味着每个提交,每个开关等待10到20秒。

is unfortunately very true. So if you have a git directory with a huge number of files inside your workspace, many git operations will start with a "counting objects..." dialog that blocks your IDE because it scans all files in the workspace. For my current 20000 files this means waiting 10 to 20 seconds for every commit, every switch, ...

在业余时间的活动中,我可以幸运地使用其他替代(将git工作目录放在工作区之外),所有的东西都觉得很厉害,合并和切换很有趣。

In spare time activities, where I can fortunately use the other alternative (having the git working directory outside the workspace) everything feels much snappier and it is fun to merge and switch.

所以如果你去大型项目,考虑git目录在工作区之外作为首选。

So if you go for large projects, consider the git directory outside the workspace as first choice.

这篇关于将Git存储库保存在Eclipse工作区内或外部是否更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆