How to set up a Git server with HTTP access on Linux

I need to create a Git repository on a Linux machine and then make it accessible via HTTP. Also need full access with one user and read-only to anon-users.

I’ve created local repositories before but I don’t know how to create this (e.g.: inside /var/www or /opt/git/…)

  • Git (on Windows using msysgit) - “compound” command
  • How do I check out an older version of a file with TortoiseGit?
  • Git installation in USB Drive that works in both OSX and windows?
  • Can you use libgit2 to clone a git repository?
  • Unable to delete unwanted commits made on github
  • Git and handling asset files
  • I tried doing this:

    -sudo Clone a GitHub repository into /var/www/repos/repo.git
    -cd /var/www/repos/repo.git
    -sudo git –bare update-server-info
    -sudo mv hooks/post-update.sample hooks/post-update
    -sudo service apache2 restart

    Then I tried to access this repository from another machine:

    -With browser : (http protocol)192.168.1.49/repo.git <– WORKS
    -With terminal: git clone –bare (http protocol)192.168.1.49/repo.git <–DOESN’T WORK

    The terminal says:

    Cloning into bare repository repo.git…
    fatal: (http protocol)192.168.1.49/repo.git/info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?

    I think maybe it’s a permissions problem. How I need to manage permissions inside /var/www?

    EDIT: Already fixed, just needed:

    -put the repository into /var/www/repos/ named repo.git
    -change the permissions of the www folder with sudo chown -R www-data:www-data /var/www
    -enable webdav with sudo a2enmod dav_fs
    -config file into /etc/apache2/conf.d called git.conf
    -create the file with users with sudo htpasswd -c /etc/apache2/passwd.git user
    -rename the pot-update file and make it executable with sudo mv /var/www/repos/repo.git/hooks/post-update.sample /var/www/repos/repo.git/hooks/post-update && sudo chmod a+x /var/www/repos/repo.git/hooks/post-update
    -update server and restart apache with sudo git update-server-info && sudo service apache2 restart

    And, to fix the problem with pushing:

    Edit the file .git/config into your repository folder (client machine) and put the username and password on the url:
    url = (http protocol)user:password@url/repos/repo.git

    So, now only I need is to set the read-only for anon-users.

  • Capistrano 3.2 could not fetch origin
  • Is it possible to clone git-p4 repo?
  • Setup a git server on a windows
  • Git tools and advices with C++
  • How to determine whether a git pull did something from a shell script
  • Git: merging public and private branches while while keeping certain files intact in both branches
  • One Solution collect form web for “How to set up a Git server with HTTP access on Linux”

    Already fixed, just needed:

    -put the repository into /var/www/repos/ named repo.git

    -change the permissions of the www folder with sudo chown -R www-data:www-data /var/www

    -enable webdav with sudo a2enmod dav_fs

    -config file into /etc/apache2/conf.d called git.conf

    -create the file with users with sudo htpasswd -c /etc/apache2/passwd.git user

    -rename the pot-update file and make it executable with sudo mv /var/www/repos/repo.git/hooks/post-update.sample

    /var/www/repos/repo.git/hooks/post-update && sudo chmod a+x

    /var/www/repos/repo.git/hooks/post-update

    -update server and restart apache with sudo git update-server-info && sudo service apache2 restart

    And, to fix the problem with pushing:

    Edit the file .git/config into your repository folder (client machine)

    and put the username and password on the url: url = (http

    protocol)user:password@url/repos/repo.git

    So, now only I need is to set the read-only for anon-users.

    Git Baby is a git and github fan, let's start git clone.