我在GitHub上使用git存储库.我知道导航和编辑存储库的基本命令,但我不知道如何从头开始设置.
我想为git repo设置我自己的服务器,这样我的好友就可以帮我解决我正在为Android开发的游戏.但我不知道怎么做!
Gitosis会是最好的选择吗?
avh*_*avh 10
IMO最简单的方法是使用ssh.如果你有一台你和你的伙伴都可以使用的机器,那么你只需要对你的存储库进行裸克隆,将它放在ssh服务器上,然后从那里克隆它.我使用我的dreamhost帐户作为服务器.
cd my-repo
cd ..
# Make a bare copy of the repo
git clone --bare my-repo my-repo.git
# Upload the bare copy to the server
# -- in this case, I've already created a /repos folder to hold the bare repos
rsync my-repo.git/ mysshserver:/repos/my-repo.git/
# Add the new server repo as a remote to your local repository
cd my-repo
git remote add origin mysshserver:/repos/my-repo.git
Run Code Online (Sandbox Code Playgroud)
然后为你的朋友:
git clone mysshserver:/repos/my-repo.git/
Run Code Online (Sandbox Code Playgroud)
唯一的技巧是确保您使用的所有用户帐户都具有repo文件夹的写权限(服务器上的/repos/my-repo.git/*).
首先,您需要创建回购(简单git init
),
其次,您需要让您的好友访问回购.
您可以使用git处理的几个选项:
file://
(局域网直接访问)第三,管理访问权限,权限等.
为此,最好的选择是gitolite,比gitosis
.回购中有一个很好的安装指南.最棘手的部分是设置对服务器的无密码访问(但这实际上与git无关).使用Ubuntu和Github你可能知道什么是公共ssh密钥.
Gitolite是迄今为止最好的选择,但有点复杂.但是,如果您不想使用gitolite,您可能仍然只能初始化repo,并使机器可访问,这是最简单的解决方案.
另请参阅免费的Pro Git书中的设置服务器.有关于gitolite和gitosis的章节.