GitHub Setup on Webfaction : How To ?

Git is a very popular distributed revision control system with an emphasis on speed. Recently for my projects I need to setup up a private Git Setup on Webfaction Server. So here is the way to Install and start using Git on Webfaction.

How to Install Git on Webfaction

  1. Log into your Webfaction Control Panel
  2. Navigate to Domains/Websites » Applications
  3. Click Add New
  4. Enter git as the application name in the Name field
  5. Select git from the App category menu
  6. Enter a password for the default user in the Extra Info field
  7. Click the Create button

The Git application provides a subdirectory, bin, which contains the Git executables. It also provides a subdirectory, repos, to store your Git repositories. repos/proj.git has been created automatically as an example.

Later you’ll have to create a Website (Domain/Website -> Website, in Control Panel), which maps this newly created Git application to some subdomain. For further explanation i’ll assume this domain to be “git.domain.com”

If you want you can delete existing proj.git by simply deleting this directory.
rm -r ~/webapps/git/repos/proj.git

Create a new Git Repository

  1. Open an SSH session to your webfaction account: ssh username@username.webfactional.com
  2. cd ~/webapps/git/
  3. ./bin/git init --bare ./repos/reponame.git
    This will create a new repository, where reponameis the name of your repository
  4. cd repos/repo.git
  5. ../../bin/git config http.receivepack true
    This will enable HTTP push to repository

Pushing local code to this repository

  1. cd /path/to/your/local/repository/
  2. git init If it’s not already under version control
  3. git add .
  4. git commit -a -m 'Initial commit.'
  5. If you want to use SSH mode then
    git remote add origin ssh://username@git.domain.com/~/webapps/git/repos/reponame.git
    For HTTP Mode
    git remote add origin http://username@git.domain.com/reponame.git
  6. git push origin master
  7. git push

Final Command should give you Everything up-to-date message.

Introduce Yourself to Git Server

It is a good idea to introduce yourself to git with your name and public email address before doing any operation. The easiest way to do so is:
git config --global user.name "Nitin Hayaran"
git config --global user.email you@yourdomain.example.com

Troubleshooting

On giving git push origin master command git may throw error error: RPC failed; result=22, HTTP code = 411. It will show you message like this:

Compressing objects: 100% (792/792), done.
error: RPC failed; result=22, HTTP code = 411
Writing objects: 100% (1148/1148), 18.79 MiB | 13.81 MiB/s, done.
Total 1148 (delta 356), reused 944 (delta 214)

This error comes when either your code size is big, or there is any file with big size. To solve this problem you need to increase buffer size in Git configuration.
git config http.postBuffer 524288000

Clone Your Repository Somewhere New

With SSH Mode Setup
git clone username@git.domain.com:webapps/git/repos/reponame.git
For HTTP Push Mode
git clone http://username@git.domain.com/reponame.git

Further Information

One Response

  1. Pramod #

    Hi.. lemme know ur mail id.. will stay in touch..

    Reply

Leave a Reply