Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git/gitolite: moving repos after setting up gitolite

Tags:

git

gitolite

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

enter image description here

like image 618
user852091 Avatar asked Aug 15 '11 00:08

user852091


2 Answers

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.

like image 168
Jan Hudec Avatar answered Sep 21 '22 16:09

Jan Hudec


I'm kind of understanding what you're saying, so please leave a comment if I'm off base, but you'll need to git clone the empty repos you created over to your machine, then you can copy the .git directory into your working directory. This should preserve the remotes.

The process should go something like:

git clone gitolite:a.git
# Message about copying an empty repo
cp -R a/.git/ /your/home/directory/a

After you've copied it, you should setup .gitignore if necessary and add/commit it, then do a git add . and something like git commit -m "initial commit" then git push origin master and it will populate the empty repo.

like image 37
Nic Avatar answered Sep 22 '22 16:09

Nic