Share remote repository using git?
I am trying to get the hang of git. We have a main git repository that is our master website, we pull data from it but cannot push to it. We also have individual repositories for each developer.开发者_Python百科 Now we want to create a repository that can pull from the main repository, but can be pushed to by a select few of developers.
The scenario is that two developers are working on a project, and need to be able to share changes and also have a log for what they are doing. How do I do so using git?
You could just use a network share and do a
git clone <central_repo> <network_share_path> --bare
This will clone your centralized repository into your shared location and set it up so it can receive pushes.
You then only have to add it to your remotes on all development machines and you are set:
git remote add development <network_share_path>
As long as both your developers can write to that directory you have set up a shared repository.
You can have a bare repository on a shared place (SFTP, HTTP, NetBios share, etc) that both developpers will push to.
There are many resources on how to do this, depending on what you'll choose an appropriate search will give you the steps to follow (or come back here if you have problems, of course).
Maybe you should create a branch on your master branch and then push the Merge Request. After that you will have to accept merge request and all changes will appear in the head (masters) branch.
As I see, you need to do some changes between multiple developers and then push it to the repo. So, merge request may help in such case.
If you want to start restriction who can do what to what branches, take a look at gitolite.
If two developers are working together, you can either create a new repo that they both access (on a network share or a server), or they can access each other's repos.
You can add another remote to your repo like this:
git remote add frank git@fserver.com:user5/project.git
git remote add john https://user5@jserver.com/user5/project.git
The first requires that there's a machine called fserver.com that's running git daemon and someone named user5 has an account there. The new remote is named "frank".
The second requires that there's a machine called jserver.com that's hosting git via http and someone named user5 has an account there. The new remote is named "john".
You can then run git fetch frank
to grab commits from frank's repo.
Here's some more info on sharing changes.
As @Tigraine said you could use a network share which works fine for smaller projects. My blog post has a step by step guide to creating a remote git repository on a windows share.
精彩评论