开发者

Share my git repository [duplicate]

This question already has answers here: How can I make my local repository available for git-pull? (6 answers) Closed 6 years ago.

Hello I start new project and I want to use git for source control. I make new folder and use command: git init to init开发者_运维知识库 repo. How can my partner to clone my repo? Cheers


There are already a lot of blog posts and tutorials covering such a basic question.

Just two examples:

  • http://gitready.com/intermediate/2009/01/24/sharing-your-changes.html
  • http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository


If you want something super basic and even git daemon is too much for you, then you can just create a unix permission group, add both users to it, create a folder and set the gid flag, and then init your git repos in there. Then you need to add a post-update hook to ensure files are always group writable.

Create the repository folder

Something like this. coders is the group you're creating. yanev and venay are users. ~/shared is where you're storing your git repos. Do this setup once.

groupadd coders
useradd -g coders yanev
useradd -g coders venay
mkdir ~/shared
chgrp coders -R ~/shared
chmod g+s -R ~/shared

Script to create git repos

Execute this in ~/shared each time you want to create a git repo.

#! /bin/bash
# Create a repo that will be accessible to everyone in the group.

if [ $# -lt 1 ] ; then
    echo Error: Need name of repo to create
    exit 1
fi

name=$1

# Create the repo
git init --bare $name

# create the hook to ensure 
hook=$name/hooks/post-update
echo -e "#!/bin/sh\n#\n# Ensure that everything's writable\n\nchmod g+rw -R $PWD/$name/\n" > $hook
chmod a+x $hook

# Start everything with group rights
chmod g+rw -R $name

Use like:

cd ~/shared
./create_shared project

Cloning

cd ~/code
git clone ~/shared/project

(Your partner will have to use the absolute path to your home folder.)

Realize that's too much work and use git daemon

You should probably just use git daemon. If it doesn't work on your network (i.e., at university), talk to your IT staff about getting it working. : )


There are lots of possible ways. the easiest, but not the best approach is 'git daemon'

You can find other options here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜