Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » EGit and linked folders in eclipse
EGit and linked folders in eclipse [message #765580] Wed, 14 December 2011 10:32 Go to next message
Jan Pohanka is currently offline Jan PohankaFriend
Messages: 29
Registered: June 2011
Junior Member
Hello,

I'm working with linux kernel using Eclipse. After some time I discovered that it is very comfortable to me to have the eclipse workspace and sources in different places, so I'm using linked folder, which contains the kernel source.

Is somehow possible to use this linked folder (which is a git repository) in git perspective? I can import it using its absolute path, but I'm not able to link it with the project then.

regards
Jan
Re: EGit and linked folders in eclipse [message #765915 is a reply to message #765580] Wed, 14 December 2011 22:13 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
It's always a good idea to keep your working directory in a different location than your Eclipse workspace. The workspace and the working directory are two entirely different things. This is true regardless of what kind of source control you're using (git, hg, svn, cvs, whatever).

You don't need links of any kind to do this. Just import the Eclipse project(s), as defined by the .project file(s) in your working directory, into your Eclipse workspace. In the case of egit, you can do the import as part of telling egit where the local repository is located, or you can do it afterwards with File -> Import -> Git -> Projects from Git.

Re: EGit and linked folders in eclipse [message #766032 is a reply to message #765915] Thu, 15 December 2011 05:27 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 14.12.2011 23:13, schrieb R Shapiro:
> It's always a good idea to keep your working directory in a different location than your Eclipse workspace. The
> workspace and the working directory are two entirely different things.
Can you please share some arguments for this assertion?

IMHO the fact that Eclipse *can* link IProjects to external locations doesn't make this mechansim the only valid one.
Not even the preferred one for these reasons:

1) The linking mechansim is insufficient because it can't deal with relative paths. This seems to be fixed in e4:
https://bugs.eclipse.org/229633
2) All scripts (e.g., Ant) that don't run in OSGi headless mode have at least hard times to deal with linked resources.
3) The idea of swapping in and out arbitrary Java projects is fundamentally corrupted by the fact that a workspace can
have only one active target platform at a time.
4) Last not least the term "work" in both "workspace" and "working directory is an indication that they're meant to be
the same thing, *the* place to work with files.

> This is true regardless of what kind of source control you're using (git, hg, svn, cvs, whatever).
Whether we agree that it's (conceptually) true, or not, neither SVN nor CVS have problems storing their working trees
*within* the workspace. From my experience that's even the most common scenario with these kinds of cource control.

The fact that EGit seems to have trouble (is that true? why?) with this common and reasonable (see the 4 reasons above)
makes me think that this is a technical issue with EGit, rather than a conceptual one with the other tools.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: EGit and linked folders in eclipse [message #766056 is a reply to message #766032] Thu, 15 December 2011 06:32 Go to previous messageGo to next message
Jan Pohanka is currently offline Jan PohankaFriend
Messages: 29
Registered: June 2011
Junior Member
Thank you for the reactions. Maybe I have not described my situation clearly.
I have the workspace directory e.g. ~/work_embedded. In the same directory there are project directories e.g. ~/work_embedded/linux-kernel and these directories have "linked folder" which points to a directory with sources (e.g. ~/src/kernel/linux-at91). That means, that the directory with sources, which contains also .git, does not contain .project file. I have found this approach in some "how to import kernel sources to eclipse" on the net, but maybe this idea is not suitable for the work with EGit.

As the eclipse can point to a .project outside of workspace directory, maybe it is better to do it in that way...

regards
Jan

[Updated on: Thu, 15 December 2011 06:57]

Report message to a moderator

Re: EGit and linked folders in eclipse [message #767648 is a reply to message #765915] Sun, 18 December 2011 15:30 Go to previous messageGo to next message
hawleyw is currently offline hawleywFriend
Messages: 5
Registered: December 2011
Junior Member
I've been trying to understand the logic behind keeping git repos and / git working directories out of my eclipse workspace and I just don't get it.

The one thing mentioned that makes sense to me is that having the repo in the workspace could slow eclipse down because of the size/number of files.

So I looked into whether it's possible to have the .git repo not be within your working project, and it is:
see progit.org blog posting 2010.4.11 on environment variables
via environment variables (not granular enough for my purposes),

or via the work-tree / git-dir config options. I've been trying to find documentation on setting this up but most of the info that I've found online is about trouble when these variables have been set by accident, not on intentionally using them.

It seems to me that the Egit team could investigate this more carefully and set the default/ recommended wizard actions to put the git repo in ~/git/<projectName>/.git and leave the working directory under the workspace. I know that I've seen arguments for keeping all code out of the workspace, but I don't understand that either, so it might be nice if the Eclipse docs on workspaces vs projects was updated and also the Egit docs were updated to give more fleshed out explanations for why we shouldn't have code in our workspace directories.

The pita for me was that I am working on a yii based web app and spent a bunch of time getting permissions set up properly for the app to run under eclipse, without being published to my main webserver and then I put it under git contol with egit, which moved it to ~/git/project/project so it won't run now until I fix up the permissions & vhosts again.
Re: EGit and linked folders in eclipse [message #767766 is a reply to message #767648] Sun, 18 December 2011 22:04 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
hawleyw skrev 2011-12-18 16.30:
> I've been trying to understand the logic behind keeping git repos and / git working directories out of my eclipse workspace and I just don't get it.
> The one thing mentioned that makes sense to me is that having the repo in the workspace could slow eclipse down because of the size/number of files.
>
> So I looked into whether it's possible to have the .git repo not be within your working project, and it is:
> see progit.org blog posting 2010.4.11 on environment variables
> via environment variables (not granular enough for my purposes),
> or via the work-tree / git-dir config options. I've been trying to find documentation on setting this up but most of the info that I've found online is about trouble when
> these variables have been set by accident, not on intentionally using them.
>
> It seems to me that the Egit team could investigate this more carefully and set the default/ recommended wizard actions to put the git repo in ~/git/<projectName>/.git and
> leave the working directory under the workspace. I know that I've seen arguments for keeping all code out of the workspace, but I don't understand that either, so it might
> be nice if the Eclipse docs on workspaces vs projects was updated and also the Egit docs were updated to give more fleshed out explanations for why we shouldn't have code
> in our workspace directories.
>
> The pita for me was that I am working on a yii based web app and spent a bunch of time getting permissions set up properly for the app to run under eclipse, without being
> published to my main webserver and then I put it under git contol with egit, which moved it to ~/git/project/project so it won't run now until I fix up the permissions &
> vhosts again.

To begin with, I agree that having the code in the workspace is perfectly fine. Workspaces are an excellent way
of being able to work on multi-repo projects.

Second you do not have to move the projects out of the workspace. It is an option, though the default. Look at the
sharing dialog and examine the options there.

-- robin
Re: EGit and linked folders in eclipse [message #768683 is a reply to message #767766] Tue, 20 December 2011 15:52 Go to previous messageGo to next message
hawleyw is currently offline hawleywFriend
Messages: 5
Registered: December 2011
Junior Member
Robin Rosenberg wrote on Sun, 18 December 2011 17:04
hawleyw skrev 2011-12-18 16.30:
> So I looked into whether it's possible to have the .git repo not be within your working project, and it is:
> see progit.org blog posting 2010.4.11 on environment variables
> via environment variables (not granular enough for my purposes),
> or via the work-tree / git-dir config options.

---> I have, since writing this post used the command
git init --separate-git-dir=/mydir/git/demo .
to set up a git repo in the /mydir/git/demo/ location with the working dir in the location of the original source code. No trouble from the command line, but not possible from egit wizard
>
> It seems to me that the Egit team could investigate this more carefully and set the default/ recommended wizard actions to put the git repo in ~/git/<projectName>/.git and
> leave the working directory under the workspace. I know that I've seen arguments for keeping all code out of the workspace, but I don't understand that either, so it might
> be nice if the Eclipse docs on workspaces vs projects was updated and also the Egit docs were updated to give more fleshed out explanations for why we shouldn't have code
> in our workspace directories.
>
> The pita for me was that I am working on a yii based web app and spent a bunch of time getting permissions set up properly for the app to run under eclipse, without being
> published to my main webserver and then I put it under git contol with egit, which moved it to ~/git/project/project so it won't run now until I fix up the permissions &
> vhosts again.

To begin with, I agree that having the code in the workspace is perfectly fine. Workspaces are an excellent way
of being able to work on multi-repo projects.

Second you do not have to move the projects out of the workspace. It is an option, though the default. Look at the
sharing dialog and examine the options there.

-- robin


-----> Robin: I've looked at the egit sharing wizard again and again and again. I've tried using it on a new, previously unshared project. I can't get it to save the git repo in the parent dir. I select the create repository in parent folder project check box and then get a message saying Creation of repositories in the Eclipse workspace is not recommended and no option to move forward or finish the wizard, only options to cancel or go back.

I've also seen references to the Egit team having "fixed" the wizard so that the non-recommended behavior is no longer possible.

I have Egit 1.1.0.201109151100r from download.eclipse.org/egit/updates and the latest stable release of eclipse (3.7.1.r2)

I have just uninstalled Egit and reinstalled it and get the same results: although the option to create the repo in the workspace exists, when I select it I am unable to move forward in the wizard. I guess for now I'm going to use git from the command line to handle this project and try to figure out where to report this bug to the Egit project folks
Re: EGit and linked folders in eclipse [message #768839 is a reply to message #768683] Tue, 20 December 2011 22:43 Go to previous messageGo to next message
Matthias Sohn is currently offline Matthias SohnFriend
Messages: 1268
Registered: July 2009
Senior Member
Did you try the checkbox "Use or create repository in parent folder of project" in the sharing wizard ?
If your project is below the Eclipse workspace this should do the trick.
Re: EGit and linked folders in eclipse [message #768863 is a reply to message #767766] Wed, 21 December 2011 00:18 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
Robin wrote:


Quote:
To begin with, I agree that having the code in the workspace is perfectly fine. Workspaces are an excellent way
of being able to work on multi-repo projects.


Workspaces are indeed an excellent way to work with multi-repo projects, I do it frequently. But I don't keep the repos in the workspace directory, which is an entirely different question.

Apparently there are unusual cases where they have to be in the workspace directory. I'm not sure I see why but let's take it as a given. In this odd case, nothing prevents you doing that as far as I know.

For sure this is not the typical case. Over the past few years I've created several dozen workspaces with projects managed by several version control systems and never once has there been any reason at all to tie the location of the repo/checkout to the location of any workspace.

Why would I want to mix them up in this way? Sometimes I work with my repositories in Eclipse, sometimes in a shell, sometimes in Emacs, sometimes in IDEA, sometimes in GitX etc etc. Any given Eclipse workspace has no special claim on any given repo. It's just one of a number of contexts in which I use it.

Similarly sometimes I want a single project to be in more than one Eclipse workspace. What would I do then if the rule is to keep project's repository in the workspace directory? I'd have to pick one of them at random.

Considering what an Eclipse workspace is for and what a Git repository is for it seems clear to me that it's best to avoid any confusion and preserve the distinction in the file system when possible. Certainly this should be the default.



Re: EGit and linked folders in eclipse [message #768873 is a reply to message #768839] Wed, 21 December 2011 00:47 Go to previous messageGo to next message
hawleyw is currently offline hawleywFriend
Messages: 5
Registered: December 2011
Junior Member
Matthias Sohn wrote on Tue, 20 December 2011 17:43
Did you try the checkbox "Use or create repository in parent folder of project" in the sharing wizard ?
If your project is below the Eclipse workspace this should do the trick.



I did try the checkbox, but it wouldn't let me continue on with the wizard.

My filesystem is set up as follows:

yiiBook/
yiiBook/demo
yiiBook/testProject
yiiBook/.metadata

with demo and testProject each being a separate projects
yiiBook is also setup as the workspace directory (thus the .metadata directory).

I'm clearly not fully understanding the best, or correct use, or ramifications of workspaces because I keep seeing posts about the ins and outs of keeping project code in the workspace directory, but I am not really grokking the outs, other then the difficulty that I'm having using the egit wizard.


Re: EGit and linked folders in eclipse [message #768901 is a reply to message #768873] Wed, 21 December 2011 02:31 Go to previous messageGo to next message
hawleyw is currently offline hawleywFriend
Messages: 5
Registered: December 2011
Junior Member
OK.

So, I've created a new directory to use as my workspace directory and I moved the .metadata directory and .git from the old workspace directory and I started fresh.

I created new projects, using the "create project at existing location (from existing source)" option and selecting the directory where the source lives.

Then I was able to use the egit wizard to create a git repository in the parent directory of the source code, which is where I want it so that I can easily use git from the command line and easily work outside of the eclipse environment.

I have to say that it would be a lot easier to get going with eclipse and egit if arguments for keeping source code in a different directory from your workspace directory were made right up front, at the beginning of all eclipse and egit tutorials. It's been confusing to have the new project wizard and the egit wizard be so non-intuative to use and that difficulty has been caused by a lack of emphasis on keeping workspaces in their own directories, away from code, in the tutorials I read when first exploring Eclipse a couple of years ago.

I am not saying this because I'm angry with the developers, I'm saying this in the hope that those responsible / capable will review the intro tutorials and documentation to try to guide people to choices that will make using this ide and its tools easier.
Re: EGit and linked folders in eclipse [message #768968 is a reply to message #768863] Wed, 21 December 2011 06:51 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
R Shapiro skrev 2011-12-21 01.18:
> Robin wrote:
>
>
> Quote:
>> To begin with, I agree that having the code in the workspace is perfectly fine. Workspaces are an excellent way
>> of being able to work on multi-repo projects.
>
>
> Workspaces are indeed an excellent way to work with multi-repo projects, I do it frequently. But I don't keep the repos in the workspace directory, which is an entirely
> different question.
>
> Apparently there are unusual cases where they have to be in the workspace directory. I'm not sure I see why but let's take it as a given. In this odd case, nothing prevents
> you doing that as far as I know.
>
> For sure this is not the typical case. Over the past few years I've created several dozen workspaces with projects managed by several version control systems and never once
> has there been any reason at all to tie the location of the repo/checkout to the location of any workspace.
>
> Why would I want to mix them up in this way? Sometimes I work with my repositories in Eclipse, sometimes in a shell, sometimes in Emacs, sometimes in IDEA, sometimes in
> GitX etc etc. Any given Eclipse workspace has no special claim on any given repo. It's just one of a number of contexts in which I use it.
>
> Similarly sometimes I want a single project to be in more than one Eclipse workspace. What would I do then if the rule is to keep project's repository in the workspace
> directory? I'd have to pick one of them at random.
> Considering what an Eclipse workspace is for and what a Git repository is for it seems clear to me that it's best to avoid any confusion and preserve the distinction in the
> file system when possible. Certainly this should be the default.

I do use multiple tools, but it is *my* problem and recommendations to either way is
my choice and applies to *my* workflow. Recommendations either way has nothing to do
with EGit. It has to do with *your* workflow and only that. EGit should not care
which way *you* do it and be happy with whatever I do.

-- robin
Re: EGit and linked folders in eclipse [message #769123 is a reply to message #768968] Wed, 21 December 2011 12:50 Go to previous messageGo to next message
hawleyw is currently offline hawleywFriend
Messages: 5
Registered: December 2011
Junior Member
Robin Rosenberg wrote on Wed, 21 December 2011 01:51
R Shapiro skrev 2011-12-21 01.18:
> Robin wrote:
>
>
> Quote:
>> To begin with, I agree that having the code in the workspace is perfectly fine. Workspaces are an excellent way
>> of being able to work on multi-repo projects.
>
<snip>

> Similarly sometimes I want a single project to be in more than one Eclipse workspace. What would I do then if the rule is to keep project's repository in the workspace
> directory? I'd have to pick one of them at random.
> Considering what an Eclipse workspace is for and what a Git repository is for it seems clear to me that it's best to avoid any confusion and preserve the distinction in the
> file system when possible. Certainly this should be the default.

I do use multiple tools, but it is *my* problem and recommendations to either way is
my choice and applies to *my* workflow. Recommendations either way has nothing to do
with EGit. It has to do with *your* workflow and only that. EGit should not care
which way *you* do it and be happy with whatever I do.

-- robin


Well, currently Egit will not work with a directory structure of:
workspace/
workspace/project1
workspace/project2


That's what I had. That's what I banged my head against the wall trying to make work. That's what I could not get through the team/share wizard.

As soon as I changed my setup to
/workspace
/project1
/project2

I was able to get Egit to create a git repo inside the project1 directory (/project1/.git)

So, if the intention of the Egit team is that the wizard should work with the first setup, then you've a bug.

Would you like me to file the bug in bugzilla, or are you going to do it?
Re: EGit and linked folders in eclipse [message #769945 is a reply to message #769123] Fri, 23 December 2011 00:19 Go to previous messageGo to next message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
hawleyw skrev 2011-12-21 13.50:
> Robin Rosenberg wrote on Wed, 21 December 2011 01:51
>> R Shapiro skrev 2011-12-21 01.18:
>> > Robin wrote:
>> >
>> >
>> > Quote:
>> >> To begin with, I agree that having the code in the workspace is perfectly fine. Workspaces are an excellent way
>> >> of being able to work on multi-repo projects.
>> >
>> <snip>
>>
>> > Similarly sometimes I want a single project to be in more than one Eclipse workspace. What would I do then if the rule is to keep project's repository in the workspace
>> > directory? I'd have to pick one of them at random.
>> > Considering what an Eclipse workspace is for and what a Git repository is for it seems clear to me that it's best to avoid any confusion and preserve the distinction in
>> the
>> > file system when possible. Certainly this should be the default.
>>
>> I do use multiple tools, but it is *my* problem and recommendations to either way is
>> my choice and applies to *my* workflow. Recommendations either way has nothing to do
>> with EGit. It has to do with *your* workflow and only that. EGit should not care
>> which way *you* do it and be happy with whatever I do.
>>
>> -- robin
>
>
> Well, currently Egit will not work with a directory structure of:
> workspace/
> workspace/project1
> workspace/project2
>
> That's what I had. That's what I banged my head against the wall trying to make work. That's what I could not get through the team/share wizard.
> As soon as I changed my setup to /workspace
> /project1
> /project2
>
> I was able to get Egit to create a git repo inside the project1 directory (/project1/.git)
>
> So, if the intention of the Egit team is that the wizard should work with the first setup, then you've a bug.
>
> Would you like me to file the bug in bugzilla, or are you going to do it?

It used to work, but if it doesn't then that's a feature. Maybe we should have a more
helpful wizards. As it now allows you to move projects to ~/Git it could also have the
option to create a repo below the workspace root and move selected projects there.

I'm not going to write it into bugzilla at time time at least. Please do if wan to.

-- robin
Re: EGit and linked folders in eclipse [message #771159 is a reply to message #769945] Mon, 26 December 2011 13:57 Go to previous message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
Robin says:

Quote:
EGit should not care which way *you* do it and be happy with whatever I do.


which is good bottom-line: wherever you decide to keep your repositories, egit should be support that. If it doesn't in some cases, that sounds like a bug that should be reported. I haven't run into any issues with this myself.

From the developer point of view, the key point is that this a decision: think about how you want organize your file system. Maybe after consideration some of you will decide that an Eclipse workspace is a sensible home for one or more Git repositories. I've given several reasons why I think this is bad idea, and I've yet to hear any reasons why it might be a good one. But that certainly doesn't mean there aren't any.
Previous Topic:Will EGit support automatic stash when doing a checkout?
Next Topic:NPE in decorator
Goto Forum:
  


Current Time: Fri Apr 19 18:11:39 GMT 2024

Powered by FUDForum. Page generated in 0.05545 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top