0

Git is a DVCS and each local git user holds a complete copy of the repository.

I am trying to set up a repository for our company's project (of small team of less than 10 people). We selected git so that we dont need to set up a server like SVN. We are using git with Visual Studio 2017. It seems that it requires us to set up / push to a remote repository either using VSTS or other remote repository such as GitHub or BitBucket, so that my teammate can clone from it.

I wonder can git work using just local repository copies in a team environment? (With no remote repository such as GitHub needed)

I have set up the repository of the project locally in my machine, how can I have my teammate clone it from me (without needing remote repository such as GitHub)?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
kvitas
  • 11
  • 1
  • 8
  • Do your teammate can access to your machine where the local repo located? – Marina Liu Mar 22 '18 at 07:17
  • I doubt it. I am not running any sorts of server here. The git repo is just on my laptop. – kvitas Mar 22 '18 at 07:26
  • 1
    A central repository is needed because it represents the authority. It keeps the version of the code that everybody agrees as **the** current version of the project. This central repo can be on a public Git provider (Github, BitBucket etc), on a server inside your company or even on your workstation but it needs to be accessible to everybody that works on the project. – axiac Mar 22 '18 at 07:56
  • https://stackoverflow.com/a/5947357/2303202 – max630 Mar 22 '18 at 07:57
  • WIthout setting up a server, I'd highly recommend looking at some of the (free) services out there that will happily host the service for you. Visual Studio Team Services is free for 5 users and Visual Studio pro or higher subscriptions give free access for extra members. Private accounts are also available on GitHub, BitBucket and other platforms. There are additional benefits to these servcies, as they provide CI/CD, Pull Requests and other features teht help with your development efforts. – jessehouwing Mar 22 '18 at 08:20
  • I am looking at GitLab right now as it has free option for unlimited # of projects and collaborators.. – kvitas Mar 22 '18 at 08:32
  • I have set up a gitlab repo, now I hv to manage the repo.. – kvitas Mar 22 '18 at 10:31

3 Answers3

1

As an addition to this answer:

  • to pull from/push to Windows, you could use just a shared folder, or set up a server. For example like this, but there are really a lot of options, from using the embedded anonymous server to setting up an IIS with smart http handler (I cannot say anything about this one).
  • you can push, especially if you don't have permanent connection, but you should be careful to not mess with receiver's work. I'd recommend to push to remote references.

For example, if you are registered as at your teammates, you push to them like:

git push teammate1 "refs/heads/*:refs/remotes/kvitas/*"
git push teammate2 "refs/heads/*:refs/remotes/kvitas/*"
....

This is basically same as they fetching from you

max630
  • 8,762
  • 3
  • 30
  • 55
0
  • If your teammates can not access to your laptop, there is no way for them to clone the git repo from your PC.

  • Even if your teammates can access to your laptop, they can just clone this repo. And your teammates can not push to your local repo with the same branch name.

In a word, you should work with remote repo for your situation since there are multiple users need to work together.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • "your teammates can not push to your local repo since your repo is not bare" it is so only for checked-out branch. Pushing to another branch would work, and I'd personally recommend pushing to "remote" references to not mess with local work. – max630 Mar 22 '18 at 07:56
0

Each user does get a complete copy of the repository, but the canonical way to share modifications accross a team is still to have a shared repository hosted on a central server.

As opposed to SVN, the setup barrier of this shared server is pretty low, though :

  • a shared folder, or a server with an ssh access is enough to hold a copy of the repo, which can be used as the shared repository
  • the next step is to manage some access rules to your repo (e.g : prevent people from doing push -f on master, ... ), and there are several free, self hosted options to add this kind of functionnality on the central servers, two of which are :

    • gitlab : comes with a complete web GUI
    • gitolite : minimalistic server, with users and access rules, which runs behind an existing ssh server
LeGEC
  • 46,477
  • 5
  • 57
  • 104