Eclipse Workspace on a network folder (UNC path) - eclipse

I am working on a project which has GitLab repository and the local repository is on a network folder so I wanted to create an Eclipse Workspace on that folder as one can share the project with the other team members but when I tried to build the project I got an error message which says that eclipse workspace can't be a UNC path, so my question is, is there any work-around way I can do this, for example is there any way I can let the OS (Windows 10) link a local folder to the one on the network so that every member would do the same and work on his own local folder and it will be automatically edited in the network folder?
Thanks

No, this is not possible since everyone needs their own cloned Git repository to work with.
For instance, switching the branch or staging files are per repository and would therefore affect everyone. When you clone a Git repository without the bare option, there will be a so-called working tree which is the location where the currently checked-out files are and this folder is not copied but mapped into your workspace. Everyone would not have a copy of those files but working with the same files.
Besides the editing conflicts you would have, another disadvantage of having a Git repository on a network drive is that it would be slower. Therefore one would not want to have this even if it were possible to have Eclipse projects on a network drive.
But since in most cases a Git repository including the working tree takes less disk space than in SVN the working copy of the same, it should not be a problem if everyone has a locally cloned Git repository.

Related

Local GIT server and Eclipse

I've worked with SVN all my life and, right now, I'm trying to learn a little about GIT. In order to do so, I have created a local private GIT server in a RaspBerry and connected it to my Eclipse.
Until now, I have created a folder in the raspberry (/home/pi/raspberry-repo.git/ ) and formatted it as a GIT repository ( git init --bare ) creating the following directory structure:
I have also successfully connected Eclipse via SSH to such repository but I have some question that may be conceptual in nature:
I already have 2 local projects in Eclipse and I have executed the Team>Share Project in them, in order to add them to the LOCAL repository in my PC. After that, I have made some commits in both projects to such local repository and pushed the changes to the remote repository in the raspberry. My doubt appears when I look the GIT perspective in Eclipse.
In SVN the usual structure is:
but in GIT the structure seems to be this:
So, AFAIK in order to download a project from a remote repository I must File>Import>Projects from GIT, select the branch and the project in such branch.
Is all this correct?
Should I use just one project per repository? (Create a folder in the raspberry for each project )
Another question is why I'm unable to see any proper file from my projects when I browse throught the Raspberry filesystem (I just see a new folder inside of the Objects folder for each commit). The repository is not stored in plain text... Is that normal or I'm making some mistake when configuring the repository folder in the raspberry?
Hope you have patience with this doubts! By the way, any GOOD tutorial is welcome (the ones I have found aren't very good)

Workspace and repo paths arrangement for eclipse and git

I've seen similar questions but some are very old and some are not quite what I'm looking for or have no answers.
I have projects in Eclipse under /workspace/project1 and /workspace/project2. They are Gradle projects and are dependent on each other. I also have /workspace/project3 which is a Gradle project but independent.
I need to "upload" them to a git repo on Bitbucket. I installed EGit to help me with this. It asks me where my local repo is located and I don't know what to tell it. Should I create a repo per workspace or per group of dependent projects or what?
For example when I right click a project and press Team > Share > Git I get to this dialog and I don't know what I should fill in there.
Each (non-bare) git repository has a work directory in which the files of the currently checked out commit (referred to as HEAD) are stored.
By default, the work directory is the parent of the git metadata directory (named .git), but it can be detached through a config setting. For example: git config core.worktree /path/to/workdir
EGit cannot deal with repositories that have a detached work directory as answered here: EGit working directory not under the local repository
But irrespective of this limitation, you cannot split the work directory of a git repository among several workspaces.
Therefore, you should move the projects to the work directory to resemble this structure:
~/git/my-repo/.git
~/git/my-repo/project1
~/git/my-repo/project2
~/git/my-repo/project3
If project3 is independent of the others, it may remain where it is or be located somewhere else entirely.
A word of caution when planning to have interdependent projects spread across several git repositories. This makes the git repositories effectively interdependent as well, but without git having a dependency management tool.
To have EGit move the projects, you would enter project1 in the Path within repository input field.
Commonly used build files like the master pom.xml or corresponding Gradle files would be located in the root of the work directory. This also eases configuration of popular build services like Travis, Codeship and friends.
A few things to understand/keep in mind:
An Eclipse workspace is a logical container of projects, not necessarily a physical container. The folder in which a worksapce is located can also be a physical container of projects, meaning the project's files can be located in a folder under the workspace folder (this is the default location if you create a new project in Eclipse). But that is not a requirement; a project that is contained within a workspace can have its contents (its files) located in any location on your file system.
In most dev setups, the local git repos are located in a "standard" location in the user's home directory, namely %USER_HOME%/git/name-of-repo. Again, that's not a hard requirement, users have the option to clone or create repos in any location they choose.
So Eclipse eGit is showing you those 2 axes of flexibility. It's asking where you want to create your local git repo, which usually is different than your workspace folder. Use the Create... button to create it. I think at that point it will auto-populate the Path within repository field. If it does not, you can name that path anything you want (usually its the same as the project name, though not necessarily)
At the end of it all you'll have your workspace (logical container) as well as a local git repo which will be the physical location of the project contents.

EGit working directory not under the local repository

The working directory should be visible on a WebDAV server and none of the parent folders should contain the repository itself.
I want to separate totally the folder for .git and the working directory (on a different drive, clean from project files and others).
Using Eclipse EGIT, the repository creation allows set of working directory (Target Location) within a path within the repository.
No way found to set GIT_DIR or working_directory within Eclipse. Linking not an option (Windows)
The project .location contains the place within the repository (and that is a binary file anyway), so that should be configurable.
Is there any way to move the working directory to a totally different place?
Is there a configuration option I have missed?
After editing the files, do I really have to push all to the server, then commit to git?
To summarize what has been written in the comments, EGit does not support Git repositories whose work directory is at a different location than the .git directory. I.e. the core.worktree configuration setting is not taken into account.
See also this open enhancement request: https://bugs.eclipse.org/bugs/show_bug.cgi?id=433451

Converting CVS multi-project tree hierarchy to Git?

I am using CVS and I have this hierarchy:
/ROOT
/JAVA
/JavaProject1
/JavaProject2
.project
/PHP
/PHPProject1
/PHPProject2
.project
In Eclipse > CVS Repository Exploring, I can see this hierarchy and I can Check Out only the project that I want.
Also I can check out (import) JAVA and PHP folders (I created them as Eclipse General project for import) to Eclipse Package Explorer and can synchronize and commit all together.
When I want to use Git, it only supports one project.
I don't want a flat hierarchy (near all JAVA and PHP project together), I want to use tree hierarchy and I want to check out only the project that I want as with CVS.
Is my CVS hierarchy possible in Git or what technique should I use?
I think you're mixing what you want to do locally with how you want
to arrange things remotely. All git commands access only the local
repository. The 'push' and 'fetch' commands appear to access a remote
repository, but in fact they effectively start each other on the remote
machine running against the local repository on that machine. So the
tasks you can do remotely are very limited. Specifically, copying "branch"
and "tag" references and the commit histories those references point at.
This means for the simple case there is ONLY the local repository,
it exists in the .git directory in the working directory.
You can arrange working directories, with their .git directories however
you wish on your local machine. Likewise, you can arrange the the remote
repositories in any way allowed by the remote hosting service. The
layouts do not have to match. If the remote is your own Linux server you
can make the layout just like your local. If the remote is (for example)
Github you're more limited.
You'll need to backup the .git directory to backup
the repository; the rest of the working directory is probably not significant. You can use git push to do this backup, as long as you never use '--force'.
Git isn't really very keen on you having multiple working directories
for one repository. It is possible, however, in the simple case they
will each have their own copy of the repository and you will need to
push/pull the updates individually either to a "central" repository
or more "randomly". None of these repositories have to be physically
"remote".
Git much prefers you to switch between branches in one working directory
and use make install style processes to send builds out.
It is also possible to have unrelated branches in one repository, but most people find this too confusing as you still only have one working directory.

How do I change my local directory in eclipse to work with git?

Long story short I moved my local project to the root of my web server. In doing so I've lost my connection to the local git files.
Here is the location of my Working Directory after pulling the source down from git.
C:\Users\Administrator\git\SiteName
subfolders are:
.git
android
website
My local webserver no longer has an android or website dierctory, but instead the contents of website are simply in htdocs.
Is it possible to reference the structure on github but keep my local files in eclipse in a different area, so I can once again merge and push files?
You can tell EGit to point to a local git repo from the Git Repositories view. Once EGit knows where your repo is, it can import projects from that repo. You can work on them in eclipse, but they point to the repo external to the workspace.
You could create symlinks to the files in the "website" directory inside your htdocs. That may or may not be what you want, since, all changes will be immediately reflected on the front end.
While importing a project, eclipse allows you to create symlinks to the files without copying them into the workspace. It's an option that appears after you click the "Advanced" button in the import dialog box. This should allow you to keep the files wherever you like, and still use them in eclipse.