I tried to setup a local git code repository for managing the code
and had some issues with gitosis. Finally I came up with a much simpler
way to create a git repository and host it on the local server.
One can follow the steps as listed below and can setup a local git server. I used Ubuntu 10.04 for this and also tried on Ubuntu server 10.04 and it works on both.
First thing you need to do is to install git on your system. For that simply run this command:-
user@ubuntu32$ sudo apt-get install git-core
One can follow the steps as listed below and can setup a local git server. I used Ubuntu 10.04 for this and also tried on Ubuntu server 10.04 and it works on both.
First thing you need to do is to install git on your system. For that simply run this command:-
user@ubuntu32$ sudo apt-get install git-core
Now git is installed onto your system. Now create a directory in which you will keep your code:-
user@ubuntu32$ mkdir git_repo
user@ubuntu32$ cd git_repo
user@ubuntu32:`/git_repo$ git init
Now add all the project files into the directory. I copied all the files I want to add to the repository.
user@ubuntu32:`/git_repo$ cp -r /home/user/projectA/* /home/user/git_repo
Now we need to add the files...
user@ubuntu32:`/git_repo$ git add .
Now we need to commit the changes. For that enter this command:-
user@ubuntu32:`/git_repo$ git commit -a -m "My first commit"
Now your files are added to the git repository.
Now to create a hosted repository of this source code, perform the following actions:-
First you need to copy the .git contents which can be checked out at later stages by users for cloning the directory. So enter the following command:-
user@ubuntu32:`/git_repo$ cp -r /home/user/git_repo/.git /home/user/hostedgitrepos/git_repo.git
Now your universal git repository is git_repo.git and you can clone it from any machine. You just need to have access to that machine and rights to access them.
You can clone it on other machine using the following command:-
aa@fed$ git clone user@<server_machine_name_or_ip>:/home/user/hostedgitrepos/git_repo.git
Now you will see the directory cloned onto your machine.
Similarly one can push the changes to the git repository or can pull the updated source code in the same fashion.
Thanks for reading..... :)