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 c开发者_如何学Pythononfig --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!
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:
- Looks correct, if what you say is correct.
- 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 git@your-domain.com-or-ip: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:
- Create a directory for your vps repositories. I use /git. Your vps user will need read/write access for this directory.
- cd to this directory
- mkdir my_repo.git && cd my_repo.git
- git init --bare
Move to your local machine:
- cd into your git repo.
- git remote add origin ssh://username@your-domain.com/git/my_repo.git
- Prepare your commits. (Have at least one.)
- git push origin master
- At this point you will be prompted for your password, if you have not set up ssh keys.
- 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!
精彩评论