Twitter Updates

Wednesday, 17 March 2010

GIT setup on webfaction

git is a popular revision control system which allow users to make local commits to capture their work in progress before it is pushed to the central repository. Most webfaction servers do not currently have git installed so you will have to compile it your self fairly trivial if you follow the instructions.

The intended work-flow is to keep committing local changes while you work on you r website and when you are happy with it you push to a secure git repo. Then make your webapp pull from the central secure repo.

$ shh
$ cd ./bin
#//Check out the latest version, currently it is
$ wget
$ tar zxf git-
$ cd git-
$ ./configure --prefix=$HOME && make && make install

#//Clean up the original stuff leaving the compiled binaries in ~/bin
$ cd ~/bin
$ rm -rf git-*
#//This bring the total from 80MBs down to 14MBs

$ mkdir ~/repo/projectname.git
$ cd ~/repo/projectname.git
$ git --bare init

Now local stuff to connect it
$ cd /path/to/your/local/repository/
$ git init #Assumes it is not already a git repo
$ touch
$ git add
$ git commit -a -m '*Added'
#//Now try to connect to server, will request your ssh password or not if you have key based ssh auth setup
$ git push ssh://

You will see this error
$ bash: git-receive-pack: command not found
$ fatal: The remote end hung up unexpectedly

This is because of an oddity in the way the .bash_profile and .bashrc are setup.
ssh only loads the .bash_profile.

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc

## MOVE THIS TO .bashrc THENthey Will both be the same
# User specific environment and startup programs
#export PATH

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc

# User specific environment and startup programs
export PATH
# User specific aliases and functions

NB: The following may be added so you can use the 'git push' shortcut (it actually runs git push origin master).
$ git remote add origin ssh://user@server-ip-or-address/~/repo/projectname.git

$ git push origin master
$ git push

Based on

1 comment:

Software quality assessment said...

I am using some other tool to carry out the process but it is very slow. I will try this one also.