Git repository on this server: Difference between revisions
| Line 27: | Line 27: | ||
git init --bare --shared=everybody | git init --bare --shared=everybody | ||
If you want to make your repository public, it has to be accessible by user <tt> | If you want to make your repository public, it has to be accessible by user <tt>gitdaemon</tt>. It is usually sufficient to give "x" permission to your home directory: | ||
setfacl -m user: | setfacl -m user:gitdaemon:x $HOME | ||
== Accessing the repository == | == Accessing the repository == | ||
Revision as of 09:26, 28 February 2011
Repository Types
This server can host two types of Git repositories.
- Central repositories
- These repositories are managed by Gitolite tool which allows convenient management of developer permissions. The world readable repositories can be browsed online.
- Personal repositories
- Any user with shell access to this server can can create his/her own git repository under his/her home directory and make it public using git protocol.
Central Repositories
Write access can only be given to users who sent their Open SSH public key to the administrator together with their university assigned login name (if any). The key can be created in Linux/Unix (or in MSysGit shell in Windows) by:
ssh-keygen
It is stored by default at ~/.ssh/id_rsa.pub.
During the key creation you will be asked for a passphrase. If you do not specify any passphrase, anybody with access to your ~/.ssh directory could access your repositories. If you specify the key, the passphrase will need to be entered whenever to use the key. By using ssh-add command you can specify the passphrase only once and the decrypted key will be remebered in the memory.
Creating central repositories
To create the repository send an email to the administrator with the name of the repository, a short description and a list of people (SSH public keys) which should have access to the repository.
Personal repositories
A personal repository can be created this way:
ssh login@rtime.felk.cvut.cz mkdir $HOME/myproject.git cd $HOME/myproject.git git init --bare --shared=everybody
If you want to make your repository public, it has to be accessible by user gitdaemon. It is usually sufficient to give "x" permission to your home directory:
setfacl -m user:gitdaemon:x $HOME
Accessing the repository
Everybody can use one of following commands to work with the code in the repository (it is not necessary add origin and configure remote branches as described above):
Central repository
Read-only access for public repositories:
git clone git://rtime.felk.cvut.cz/repo-name.git
Access managed by gitolite (for users with registered SSH key):
git clone git@rtime.felk.cvut.cz:repo-name
Personal repository
Read-only access for public repositories: git clone git://rtime.felk.cvut.cz/~yourlogin/repo-name.git
First push
After an empty repository is created either by you (personal) of by an admin (central), you can push (upload) the data to it:
- (Optional -- needed only for personal repos): Setup passwordless login to the server
- Install Git on your local computer
For git 1.6.2 and newer
- Clone the empty repository.
- Put your sources into your cloned repository
git add . # tells git to track all files in your project git commit # commits the added files to the repository
- Push your sources to the server
git push
For older git versions
- Put your sources into your local repository
cd your/project git init # initializes git repository in your project's directory git add . # tells git to track all files in your project git commit # commits the added files to the repository
- Then "connect" your repository to the one on this server (replace login by your login and repo-name by the name of repository created for you)
git remote add origin git@rtime.felk.cvut.cz:repo-name # this is for central repos git config branch.master.remote origin git config branch.master.merge refs/heads/master
- Push your sources to the server
git push --all
Pushing to non-master branches
If you are not allowed to push to the master branch but a different one, you have to push like this:
git push origin master:your-branch
which pushes our local master branch to the remote your-branch
To make this behavior default run
git config remote.origin.push master:your-branch
And from now on, it is sufficient to run only
git push
Contributing to other projects
Using personal repository to contribute to other projects
If you do not have write access to the repository of some project (not necessary a central repository on this server), you can work in your personal repository then ask somebody with write access to merge your changes.
- Clone a central repository
git clone git://rtime.felk.cvut.cz/project.git
- Add your rtime personal repository as remote (using SSH access)
git remote add personal yourlogin@rtime.felk.cvut.cz:myproject.git
- Edit files in project...
- Commit your changes
git commit ...
- Push your changes to your personal repository
git push personal
- Write email to somebody with write access to merge changes in git://rtime.felk.cvut.cz/~yourlogin/myproject.git
Merging changes from forks
git remote add fixes git://rtime.felk.cvut.cz/project/forkname.git git fetch fixes (or git remote update) git merge fixes/master