http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/#apachehttp
#yum install git
(using rpmforge repository)
Creating and sharing a repository
Creating a repository is easy! Simply create a folder and type git init.
mkdir newrepo cd newrepo git init
Once created, we can copy/create our files (think svn import) and then do:
git add . git commit
Share over apache http
Preparing the repository# On the web server we assume var/git as the central repository place and will create a new project-X dir $ cd /var/git $ mkdir project-X $ cd project-X # now we initialize this directory # but instead of using git init, we use git --bare init # "A short aside about what git means by bare: A default git repository assumes that you will be using it as your working directory # , so git stores the actual bare repository files in a .git directory alongside all the project files. Remote repositories don't need copies of the files on the filesystem unlike working copies, all they need are the deltas and binary what-nots of the repository itself. This is what "bare" means to git. Just the repository itself." $ git --bare initNow that we created the project directory we need to give apache access to it:
- Be sure to set the correct permissions on the /var/git directory so that it can be read by the webuser. chown -R apache:apache /var/git/project-X
- If you have selinux enabled: chcon -R -t httpd_sys_content_t /var/git/project-X
- Enable the post-update hook: chmod +x /var/git/project-X/hooks/post-update
When you did not set the post commithook:
$ git clone http://git.yourdomain.com/project-X Initialized empty Git repository in /Users/mydir/project-X/.git/ fatal: http://git.yourdomain.com/project-X.git/info/refs not found: did you run git update-server-info on the server?Then you can need to run it manually the first time
$ cd /var/git/project-X $ sudo -u apache git update-server-info
Preparing apache
This document assumes you have a basic apache setup. And you have virtual name server working. Most of it is standard acces to the directory.
To allow write access, we need to have Webdav enabled.
http://www.kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt
This will add a virtual server that has access to the /var/git directory using simple browsing.Servername git.mydomain.com DocumentRoot /var/git DAV On Options +Indexes +FollowSymLinks AllowOverride None Allow from all Order allow,deny
In case you are experiencing trouble:
- Remove the restrictions from welcome.conf: in this default file, it disables the index option. Error: ...
- Note the + before the options, to allow the merge of permissions
We control access to your repository using apache groupfiles and password files
ServerName git.yourdomain.com DocumentRoot /var/git DAV On Options ExecCGI FollowSymLinks Indexes # Deny everyything here Deny from all AuthType Basic AuthName "git repository" AuthUserFile /var/git/htpasswd.git AuthGroupFile /var/git/htgroup.git Allow from all Order allow,deny Require group project-X-read Require group project-X-write
Accessing the repository
Git uses curl to access http repositories. Because our repository is now protected we need to create an entry in our $HOME/.netrc file
$ cat $HOME/.netrc machine git.yourdomain.com login reader password readerNow you should be able to clone project-X
$ git clone http://git.mydomain.com/project-XPossible Errors
Trying update error: Cannot access URL http://git.yourdomain.com/project-X/, return code 22 error: failed to push some refs to 'http://git.yourdomain.com/project-X'If there's something wrong with the permissions. Maybe you don't have webdav enabled, the user is in the wrong group, or filepermissions are not set correctly. Check your apache error_log
$ git clone http://git.yourdomain.com/project-X $ git push fatal: git-push is not available for http/https repository when not compiled with USE_CURL_MULTIerror: failed to push some refs to 'http://git.yourdomain.com/project-X'Either you compile your git client with the correct curl options. Or you can alternatively mount the remote repository as webdav share and access it via file:// references. See http://wiki.dreamhost.com/Talk:Git
The following happens if your curl library was not compiled with the correct options to post to http://kerneltrap.org/mailarchive/git/2008/1/13/564431 After a bit of research it seems that CURL compilation into GIT was not entirely successful for the Git on Mac OS X. As I was already mounting the git repository via WebDAV you an push and pull to your locally mounted repository by replacing the http URL with the path to your mounted WebDAV (/Volumes//). This worked pretty well for me and works well with Dreamhost with very little configuration.
$ git push Fetching remote heads... refs/ refs/tags/ refs/heads/ No refs in common and none specified; doing nothing.
This happens when you cloned an empty repository: Because you cloned an empty repository , you need to specify the origin and master , after this first push, you can use git push as usual
$ git push origin master
No comments:
Post a Comment