Назад | Перейти на главную страницу

Как настроить публичный репозиторий Git в Unix

Я создал несколько частных репозиториев, в которых я совершаю коммит через SSH, но у меня проблемы с настройкой общедоступного. Вот что я сделал до сих пор:

Войдите на мой сервер через ssh

$ cd public_html/repos/
$ mkdir test
$ cd test 
$ git --bare init
$ touch git-daemon-export-ok # tell GIT it's ok to export this project
$ chmod 777 -R ../test #making sure the directory had full read write execute permissions
$ exit # exit out of ssh

$ mkdir test_porject
$ cd test_project
$ touch README.txt
$ git init #Initialized empty Git repository in ~/test_porject
$ git add .
$ git commit -m "initial commit"
$ git remote add origin http://repos.mydomain.com/test
$ git push origin master

это ошибка, которую я получаю: ошибка: запрошенный URL вернул ошибку: 500 при доступе http://repos.mydomain.com/test/info/refs фатальный: HTTP-запрос не удался

А ???? Не уверен, почему это не работает. Если вы пойдете в http://repos.mydomain.com/ Я не получаю ошибок. Любая помощь приветствуется.

Я подозреваю, что ваша стенограмма, приведенная выше, на самом деле не отражает фактические команды, которые вы ввели. Вот как вы можете настроить http-доступный репозиторий, а команды (и вывод) здесь именно то, что я ввел:

Создание репозитория:

$ mkdir -p public_html/git
$ cd public_html/git
$ git init --bare testrepo.git
Initialized empty Git repository in /home/lars/public_html/git/testrepo.git/
$ cd testrepo.git
$ mv hooks/post-update.sample hooks/post-update
$ chmod 755 hooks/post-update

Заполняем его некоторыми коммитами:

$ cd ~/tmp/
$ mkdir testrepo
$ cd testrepo
$ git init
Initialized empty Git repository in /home/lars/tmp/testrepo/.git/
$ echo this is a test > myfile
$ git add myfile
$ git ci -m 'added myfile'
[master (root-commit) eea6564] added myfile
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 myfile
$ git remote add origin ~/public_html/git/testrepo.git
$ git push origin master
Counting objects: 3, done.
Writing objects: 100% (3/3), 233 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To /home/lars/public_html/git/testrepo.git/
 * [new branch]      master -> master

Клонирование через http:

$ cd ~/tmp
$ git clone http://localhost/~lars/git/testrepo.git testrepo-cloned
Cloning into testrepo...
$ ls -A testrepo-cloned/
.git  myfile

Если вы пройдете через это, и это не сработает, я сильно подозреваю, что проблема в конфигурации вашего веб-сервера.

$ git удаленное добавление источника http://repos.mydomain.com/test

$ git push origin master

Вы пытаетесь нажать на открытый HTTP-репозиторий? Это не сработает.

http://book.git-scm.com/4_setting_up_a_public_repository.html

[..] Кто-нибудь еще должен иметь возможность клон или вытащить с этого URL [..]