views:

26

answers:

1

I just got hold of an openSuse 10.3 VPS. I really don't know much about Unix and SSH and this stuff but I'd like to use my server to host a GIT repository. This seems simple enough to me...

Here is what I did:

I SSHed into my server and installed GIT (I guess), simply by entering

# yast --install git

Then some magic happened and obviously, git was installed. Great! I also created a user:

# git config --global user.name ...
# git config --global user.email ...

Then, I copied the source code from my local disk to the server. Since I don't really know where to put such stuff on an openSuse, I chose home/myRepository

Next, I created a repository there and added the existing files, using the following commands:

# cd home/myRepository
# git init
# git add .
# git commit -m 'Add code'

As far as I can tell, everything worked. E.g. git log shows my commit.

No here are my questions: 1) Did I do everything fine so far? Would home/fooBar be an appropriate directory to hold a repository? 2) More important: How on earth do I access the repo from my local machine= I wanted to create a local clone with Xcode 4, using the URL

git://123.456.789.012//home/myRepository

but this obviously didn't work. I have no clue, wether this URL is correct. Also, do I have to create a new user, to access the repository from my local machine?

You see, I've quite a lot of questions and I'm obviously lacking some basics. I googled for quite some time but I didn't find a guide suitable for my problems. Any answers and helpful links would be highly appreciated. Thanks!

+1  A: 

You will probably want to use something like gitosis to host your git repository securely. I am familiar with Debian Linux mostly and originally found this post (http://blog.agdunn.net/?p=277) when I got started. You may have to find the equivalents on your openSuse install.

To answer your questions:

  1. Looks correct, if what you say is correct.
  2. You need to either install gitosis or access it through a user account over ssh.

To install gitosis, you basically need to install python and create a git user on your vps. You will need to understand ssh keys. Once you do this you can clone the repository by 'git clone [email protected]:your-repo.git'. You administrate your repositories through a gitosis-admin repository and make it effective by a simple 'git push'. You can create groups for all of the users that you have ssh public keys for and grant read/write access to specific repositories.

By doing what you have already done, you can get up pretty quickly by the following:

On your VPS:

  1. Create a directory for your vps repositories. I use /git. Your vps user will need read/write access for this directory.
  2. cd to this directory
  3. mkdir my_repo.git && cd my_repo.git
  4. git init --bare

Move to your local machine:

  1. cd into your git repo.
  2. git remote add origin ssh://[email protected]/git/my_repo.git
  3. Prepare your commits. (Have at least one.)
  4. git push origin master
  5. At this point you will be prompted for your password, if you have not set up ssh keys.
  6. After this your repository will be pushed to your vps over ssh.

To create more repos, you have to get on to the server and repeat steps 2-4 of the server steps. The trickiest part is getting all of the paths right, or you will get refused pushes/clones/pulls, etc. I am forced to use this method on "quasi-vps" machines without root access. Typing passwords gets old quick....

I think you should be able to follow the gitosis directions on the blog above. Only the package manager commands will really be different, and it looks like you know how to use yast. Man pages (man adduser, etc.) should be able to get you the rest of the way!

Hope this helps. Let me know if you have questions and if this helps!

nearapogee
Thank you so much, I'll give that a shot. So, git only provides the repository but not the means to access it remotely? So, to host a git repository on a server, I need to install some extra software (like gitoise) or access it via SSH? I remember setting up a SVN Server once and as far as I remember, after installing Subversion and setting up my repository, I was good to go.
Phlibbo
Git over SSH is pretty simple. You are going to SSH into your VPS, right? But really gitosis, is really the way to go and has very low overhead.
nearapogee
Unix traditionally uses a bunch of focused tools to get a job done, this goes a long ways back to the start of Unix.The other option is to use [git-daemon](http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html). I have never used it, because gitosis is so easy, but you could certainly start up git-daemon and have everything under the git umbrella.FYI - Git can be transferred over ssh, http, and the git protocol.
nearapogee