Is it safe for multiple users to use a Git repo on a shared network drive? - eclipse

We're using Eclipse (with the eGit plugin) and I want to host a repo on a shared network drive that several users have write access to.
Can users all point at the same original repo (on the shared drive) or would it be better for each user to clone the repo to their local drive, work off this local version, and push changes to the networked original as required?
Eclipse seems to allow you to "import" (to your Eclipse workspace) a project from a Git repo, but that imported project doesn't seem to be monitored by Git until you choose to "Share project". At this step the working directory becomes that of the repo's working dir for that project. Presumably all users sharing this project would have the same working dir i.e. that of the repo on the shared drive.
I am not clear on the implications of this, but it doesn't seem like a good idea, on first inspection! How will it handle basic problems like 2 users trying to open the same file for editing simultaneously, for instance?
Thanks.

It's better that each person has their own repo.
Clone you current repository as a bare repo and place it on the network drive.
e.g.
git clone --bare /path/to/current/cool_project cool_project.git
Move the cool_project.git to your network drive, and get everyone to clone from that. Bare repos don't have a working directory, hence the name, so they are safe to push to.
See the chapter 4 of the Git Pro book - Git on a Server, and specifically chapter 4.2 for more details.

From the sound of it you are talking about each user pointing to the git repository over the network and not having individual git repositories on each developer's computers and then pushing to a 'central' repository. If I am correct in reading your question that is not a great way to take advantage of what git has to offer. Git is a distributed version control system so everyone should have their own repository and push the changes to a central repository that you do your CI builds off of.

Related

Eclipse Workspace on a network folder (UNC path)

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.

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)

Eclipse - sharing project directory with multiple users

We are trying to set up Eclipse so that two users can share the same project directory on our server. Is this possible? Every time we try, it creates a new folder and project.
Thanks!
Chris
No, this isn't possible. Eclipse only supports a single user accessing a workspace (not just a project) at a time.
Use a source control system such as Git or SVN to share code. Eclipse supports many such systems and has extensive sharing support in the 'Team' menus.
The best way to do this would be to use source control.
Sharing the actual workspace or the files with different eclipse instance is a recipe for trouble.
An easy way to do this would be to install git on your machine and also on his machine. Eclipse actually already has git in it ready to go so you probably dont need to install anything.
The one with the files locally will create a repo locally on his computer and commit the files to it.
Next you want to init a new empty repository on a shared folder and push your local chances to this as you would to github for example.
Your partner can then git clone from this repository to his machine and work locally.
Each of you will develop on your own copy and commit your changes locally. You will share your changes by pushing your commits in that central repo and pulling from it to get changes from your partner.
You could also just open an account on GitHub, GitLab or BitBucket (there are many others too) and use that instead of a shared folder. big advantage with these services is that they will be available from anywhere.

How to set up GIT as version control tool for a small team

We are using Eclipse with a SVN client plug-in. This client needs a server running; what about Git? We need to work in a LAN environment without internet access. I have read some basic tutorials about using Git with Eclipse. If I got a Java project in my Git repository, how can I share it with my teammate?
Even though you can share your local repositories, I would suggest setting up a server. There many free alternatives like:
gitlab (http://gitlab.org)
gitorious (http://gitorious.org)
gitolite (https://github.com/sitaramc/gitolite)
gitblit (http://gitblit.com/)
But IMO the best one is Atlassian Stash which for small team will cost you only $10.
if you need to share it, you need some way to access it from each other. Bitbucket is great for small teams who need private code.
If you are always using it from inside a LAN one of you should set up a shared section which you can all push your git changes too (a shared folder or shared drive is good enough) but i would recommend using github / bitbucket if possible
from a command line (can probably use it within eclipse too)
git clone file:////192.168.1.100/code
and then you can psuh and pull from 192.168.1.100/code assuming you have write permissions there
if you're coming from subversion to git, you will be faced with the concept of local repository vs shared repository. You will be able to have a local repository on your computer where you can do as many commits as you want and then only push relevant changes to the shared repository (the one that your teammates will be able to see).
Here's an useful link on the possibilities to share a repository: http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/ (ignore the last one, GITHUB, which will require internet access).
In your particular situation I would recommend sharing via SSH or via GIT daemon.
I also really recommend you to take a look on Eric Sink's book here. He's even offering hardcopies for free!
as suggested you can run your own instance of gitolite or gitlab, but for a rudimentary solution i suggest you just check the following answer:
https://serverfault.com/a/113688/181010
basically you can use any folder as a shared repository as long as all users can access the files either locally or via ssh. that link discribes how to tell git to create its file with rights that are appropriate for usage by all users of one unix group (instead of only the single user owning the files).

How to access Xcode project with iCloud

I recently bought a MacBook Pro that I will use to develop an iPhone app. I want to be able to transfer the Xcode project between my Macbook and my iMac in the same manner that Word documents can be transferred using iCloud. Is there a secure way this can be done?
iCloud or version management?
iCloud might sound good idea for syncing Xcode projects, but it actually leads to problems. You should use git instead. I recommend to use bitbucket (online git repos), which is free. You can host private or public projects on bitbucket. I like bitbucket because of free private repos. GitHub does not provide free private repositories!
Easy to share
When you are done editing your code in one machine, you can commit changes and then push your committed changes into a remote repository. When you are open your project on another computer, you have to fetch it (pull) from the remote repository.
By using git, you can share your code easily with other team members, too.
How to
See more here:
Enable Access to Your Source Code Repositories
Save Project Changes
I'm using dropbox to sync my xcode projects across 2 macs. I had no issues so far but I would recommend not to work on a project simultaneously, so make sure to close it on one machine before you open it on another.
Here is how I use iCloud Drive as a remote git repo:
Create a new Xcode Project (with git versioning turned on) in a local directory, for example ~/Xcode-Projects-Local/GiTest
Clone the new local directory to a remote directory, for example iCloud Documents:
git clone --bare --no-hardlinks ~/Xcode-Projects-Local/GiTest ~/Documents/Xcode-Projects/git/GiTest.git
Add the cloned directory as a remote to the local repo:
cd ~/Xcode-Projects-Local/GiTest
git remote add -f iCloud ~/Documents/Xcode-Projects/git/GiTest.git
On a different Mac, clone the remote repo into a new local directory:
git clone ~/Documents/Xcode-Projects/git/GiTest.git ./GiTest
Enjoy!
For an existing project, just skip step 1. Note the --no-hardlinks option to make sure that hard links won't confuse iCloud drive.
For those wondering 'why not just put the project dir directly on the iCloud drive': Xcode always had and -- as of Xcode 10 -- still has problems with that eventually resulting in a corrupted repo.
If you are planning to work on machines with different screen resolutions, for example Macbook and iMac, you should git-ignore directories named project.xcworkspace/xcuserdata.