For the past 1 month, especially en-route preparations for FOSS.IN 2009 I wanted to have a complete repository on my hard disk from where people can checkout, commit src code, schematics, technology information and do whatever needed without the necessity of INTERNET connectivity. Thats where git drew my attention. I have been a cvs / svn user for long time now and the very fundamental design aspect of git / any distributed version control system makes me happy as it is just what a developer like me needs.
So here goes a quick how-to (more of a note to self) on how I setup a remote git repo on one of the servers I have ssh access to.
1. SSH into your remote server (ssh uname@remoteserver)
2. Say, you are starting off setting up a git setup on this remote server. Create a directory by name say git (In the below example I put it in the home directory). All projects shall go into this directory.
uname@remoteserver$ mkdir ~/git
3. Now, create a project.git directory. If your project name is ledblink then do the following.
uname@remoteserver$ mkdir ~/git/ledblink.git
4. Initialise a bare git directory
uname@remoteserver$ cd ~/git/ledblink.git
uname@remoteserver/git/ledblink.git$ git – -bare init
5. Edit the description file to describe the project [Optional of-course]. Then edit the config file to enable reposharing by adding the line “sharedrepository = 1” under the [core] section.
6. Setup appropriate permissions. In the below example user only rights.
uname@remoteserver/git/ledblink.git$ chmod -R g=u .
uname@remoteserver/git/ledblink.git$ find . -type d | xargs chmod g+s
So all is done on the server side. Go back to your local machine.
7. Go to the folder you want to be version control or create a fresh directory where you will put your project files. Lets say localprojectrepo is the directory name. Change directory into the localprojectrepo and do the following.
uname@localhost/localprojectrepo$ git init
uname@localhost/localprojectrepo$ touch samplefile.txt
uname@localhost/localprojectrepo$ git add .
uname@localhost/localprojectrepo$ git commit -m “First commit”
Your local git repository is created. Now lets add the server as remote so that a push “syncs” the changes to the remote server.
uname@localhost/localprojectrepo$ git remote add origin uname@remoteserver:<pathto>/git/ledblink.git
uname@localhost/localprojectrepo$ git push origin master
Life is good! To take backups of your remote git repo, use your favourite means to copy the ~/git directory you create on the remote server. Thanks to good old friend Anurag for helping me through the details.
You might also want to set up gitosis if you want to centrally manage multiple git repositories.
Hi,
Just want to let you know that your blog engine is doing some nasty things with the links provided by your RSS Feed.
If I try to open this link: http://www.tuxmaniac.com/?p=201
your blog answers me with a 301 message with the following location:
://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/
Since the protocol is missing, the browser makes a request to:
http://www.tuxmaniac.com/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/
The server answers again with a redirect pointing to:
://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/
and then the browser makes a request to:
http://www.tuxmaniac.com/://www.tuxmaniac.com/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/
This keep happening a couple more times until I reach the following URL:
http://www.tuxmaniac.com/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/://www.tuxmaniac.com/blog/2009/12/14/setting-up-a-remote-git-server/
Good luck fixing this.
please explain in more detail…..
good information you
write it very clean. I am very lucky to get this tips from you.
Very efficiently written information. It is going to be beneficial to anybody who usess it, including myself. Keep up the great work – for positive i will try more posts.