Setup Git Server with deprec

Git is a distributed source control system written by Linus Torvalds. It's the awesome.

You'll need to install Git on your remote servers if you deploy projects with Capistrano that reside in Git repositories.

If you want to learn to use Git, I recommend the following resources:

* Git Peepcode screencast * Git with Rails Tutorial by Scott Chacon

# cheatsheet
cap deprec:git:install HOSTS=sh03
cap deprec:git:add_user HOSTS=sh03
cap deprec:git:setup_remote_repos HOSTS=sh03
git remote add sh03 git@sh03:/var/git/test_project.git
git fetch sh03

Install git

cap deprec:git:install HOSTS=sh03

If you only want to use git as a client on this machine then your're done. If you want to host git repositories then read on.

Add git user

Any users you add will have access to all of your git repositories on this server. If you want to grant more granular access then write your own recipes for that (and let me know about them!). Adding a user involves copying their SSH public key to the authorized_keys file for the git user. It seems everyone accesses git as git@hostname. I'm new to git so I'll go with the flow for now.

cap deprec:git:add_user HOSTS=sh03

Add git keys for which user?  |mbailey|

You can test your access this by trying:

ssh git@sh03

Note that the git user has a restricted shell (/usr/local/bin/git-shell) so you can't do much with it. Just check it doesn't display "Permission denied".

Setup a new repository

If a local git repo doesn't exist in the current directory, deprec will create one. It will then create a remote repos on the server.

cap deprec:git:setup_remote_repos HOSTS=sh03
enter name of project(no spaces)
test_project

New remote Git repo: git@sh03/var/git/test_project

You can now add it as a remote with:

git remote add sh03 git@sh03:/var/git/test_project.git
git fetch sh03

Delete git user
From time to time you may want to remove a users access to git.

cap deprec:git:del_user HOSTS=sh03

Select a user to remove git access from:
1. claudette
2. mbailey
?  1

List git users
Note that the list is obtained from the first server only. In general you should restrict the user management commands to one server at a time or make sure all the servers have the same users.

cap deprec:git:list_users HOSTS=sh03

Git users:
mbailey


Attachments