Git / gitolite:设置gitolite后移动仓库 [英] Git/gitolite: moving repos after setting up gitolite

查看:159
本文介绍了Git / gitolite:设置gitolite后移动仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正处于让Git和Gitolite工作的最后阶段。这是目前的情况:

解决方案

Gitolite管理下的存储库没有工作副本。所以你必须做的是创建另一个工作副本的仓库,提交数据并将它们推送到gitolite管理的仓库。最简单的事情就是直接在服务器上执行该操作。因此,在每个 www 目录下,请执行:

  cd / home / X / www 
git init
git remote add origin /home/gitolite/repositories/X.git
git add。
git commit
git push origin

现在您拥有存储库中的数据,这是很容易的部分。我假设相同的用户帐户可以访问gitolite存储库和服务器数据(正如您在聊天中所说的那样),这会使问题变得更容易。



现在,存储库没有交替,所以你有两份数据。要删除它们,对每个站点来说可能是最简单的做法:

  cd / home / X 
git clone -s /home/gitolite/repositories/X.git www.new
mv www www.old
mv www.new www
rm -r www.old

(克隆的 -s 选项确保 / home /X/www/.git 版本库不会复制 /home/gitolite/repositories/X.git 中的数据)。最后你必须安装一个钩子。这已经在这个问题中解释过了,但你的情况稍微容易一些。由于数据存在于同一台服务器上,并位于同一用户下,因此您可以在所有包含以下内容的gitolite存储库中安装更新后的挂钩:

 #!/ bin / sh 
cd / home / X / www
git pull

如果您想将存储库和Web服务器移动到不同的服务器上(我建议这样做,因为Web服务器如果面向外,应该位于非军事区),而git服务器在另一条防火墙后面的内部网络中效果更好),那么您当然需要在其他问题中描述的ssh触发器事件。


I am in the final phases of getting Git and Gitolite working. This is the current situation:

解决方案

The repositories under Gitolite management don't have working copies. So what you have to do is create another repositories with working copies, commit the data and push them to the gitolite-managed ones. The easiest thing is to do that on the server directly. Therefore under each of the www directories, do:

cd /home/X/www
git init
git remote add origin /home/gitolite/repositories/X.git
git add .
git commit
git push origin

Now you have the data in the repositories, which was the easy part. I am assuming the same user account has access to both gitolite repositories and the server data (as you said in chat), which makes the issue significantly easier.

Now the repositories don't have alternates, so you have two copies of the data. To remove them, it's probably easiest to for each site do:

cd /home/X
git clone -s /home/gitolite/repositories/X.git www.new
mv www www.old
mv www.new www
rm -r www.old

(the -s option to clone ensures the /home/X/www/.git repository won't copy data from /home/gitolite/repositories/X.git). And finally you have to install a hook. It's already explained in this question, but your situation is slightly easier. Since the data live on the same server and under the same user, you can simply install a post-update hook in all the gitolite repositories containing just:

#!/bin/sh
cd /home/X/www
git pull

If you ever want to move the repositories and web server to separate servers (which I'd recommend, because the web server, if it's facing out, should be in a "demilitarized zone", while the git server is better off in your internal network behind another line of firewalls), you will of course need the ssh trigger thing described in that other question.

这篇关于Git / gitolite:设置gitolite后移动仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆