如何初始化一个新的eclipse(neon)java项目的git [英] How to initialize git for a new eclipse (neon) java project

查看:241
本文介绍了如何初始化一个新的eclipse(neon)java项目的git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我安装了eclipse Neon的全新副本,并在新的闪亮的工作区中创建了一个新的gradle java项目。将git添加到聚会的最佳做法是什么?

我读到在项目目录中初始化git是真是一个坏主意



什么是特别好主意然后?!



谢谢!

解决方案

好主意是将git init 项目的父文件夹与主工作区文件夹 EM> 即可。



如果你让Egit git启动你的项目(右键点击项目 - >团队 - >共享项目 - > Git - > .. 。)并选择一个外部文件夹作为仓库,比如c:\ users \ john \ my-git-repository。



然后,您将拥有两个文件夹:


  1. c:\ users \ john \ my-git-repository 包含 \.git 文件夹和 \\ \\< my-project> 文件夹

  2. c:\users\john\< eclipse-workspace> code> eclipse workspace文件夹,它不包含你的项目文件夹(记住,eclipse workspace只是一个用于项目的逻辑容器,它们不需要物理存在) li>

另一个选项是在工作区内创建一个文件夹,将该项目创建为该文件夹的子文件夹,然后git init该文件夹。这样:


  1. c:\users\john\< eclipse-workspace> \shared -projects \< my-project>

您将在 \shared-projects 文件夹(或者通过git init的命令行或者通过Eclipse向导),它将包含 \.git 文件夹, \< my-project> 文件夹以及您想共享的任何其他项目。


记住Eclipse为什么建议将工作空间保存在工作空间之外( https://wiki.eclipse.org/ EGit / User_Guide#Creating_Repositories ):
$ b


将您的Repository放在Eclipse Workspace之外是一个好主意。 >

有以下几个原因:


新版本库将考虑Ecli的完整文件夹结构作为(潜在)内容的pse工作区。这可能会导致性能问题,例如在提交前计算更改(例如,将扫描完整的.metadata文件夹)。


如果您的git repo位于 \shared-projects 文件夹中,则存储库 NOT 将Eclipse工作空间的完整文件夹结构视为(潜在)内容,并且不会扫描.metadata文件夹,因为它位于回购站之外。回购的唯一内容将是您的共享项目!


I installed a fresh copy of eclipse Neon, and created a new gradle java project in a new and shiny workspace. What is the best practice for adding git to the party?

I read that initializing git in the project directory is really a bad idea.

What is a particularly good idea then?!

Thanks!

解决方案

The good idea is to git init a parent folder of the project different from the main workspace folder.

This is exactly what happens if you let Egit git init your project (Right click on project -> Team -> Share Project -> Git ->...) and select an external folder as repository, say c:\users\john\my-git-repository.

You will then have two folders:

  1. c:\users\john\my-git-repository containing the \.git folder and \<my-project> folder
  2. c:\users\john\<eclipse-workspace> the eclipse workspace folder, which will NOT contain your project folder (remember that eclipse workspace is just a logical container for projects, they don't need to be physically there).

Another option is to create a folder inside the workspace, create the project as a subfolder of that folder and then git init that folder. This way:

  1. c:\users\john\<eclipse-workspace>\shared-projects\<my-project>

You will create the repository in the \shared-projects folder (either by command line with git init or from whithin Eclipse with the wizard), which will contain the \.git folder, \<my-project> folder and any other project you want to share.

Remember why Eclipse suggests to keep repositories outside the workspace (https://wiki.eclipse.org/EGit/User_Guide#Creating_Repositories):

It is a good idea to keep your Repository outside of your Eclipse Workspace.

There are several reasons for this:

The new Repository will consider the complete folder structure of the Eclipse workspace as (potential) content. This can result in performance issues, for example when calculating the changes before committing (which will scan the complete .metadata folder, for example)

If your git repo is in the \shared-projects folder the repository will NOT consider the complete folder structure of the Eclipse workspace as (potential) content and will NOT scan the .metadata folder since it's outside the repo. The only contents of the repo will be your shared projects!

这篇关于如何初始化一个新的eclipse(neon)java项目的git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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