Distributed Version Control system: Difference between revisions

From CSU-CHILL

No edit summary
m (→‎Routine Usage: Added section on listing repos)
 
(3 intermediate revisions by 2 users not shown)
Line 9: Line 9:


==Key Generation==
==Key Generation==
We need a ssh public key file (id_rsa.pub) from each person who will needs to read or write from/to the repository.  You may already have such a file in your ~/.ssh directory.  If not, you can create one on the machine from which you would like to access the CHILL Git repository :
We need a ssh public key file from each person who needs read or write access to the repository.  You may already have such a file (usually called id_rsa.pub) in your ~/.ssh directory.  If not, you can create one on the machine from which you would like to access the CHILL Git repository :


ssh-keygen -t rsa
ssh-keygen -t rsa
 
 
You will be prompted for a directory (the default .ssh is fine) and a passphrase. A passphrase is optional, but recommended -- you'll need to enter it each time you access the remote repository.
You will be prompted for a directory (the default .ssh is fine) and a passphrase. A passphrase is optional, but recommended, you'll need to enter it each time you access the remote repository.
 
{{Note|It is not necessary to use the RSA cypher, if your system already has a key with a different cypher (such as DSA), that will work too, but the file names will be different. Contact your system administrator.}}


This will create a file called ~/.ssh/id_rsa with your private key and ~/.ssh/id_rsa.pub with your public key. Copy the public key to some convenient location, then rename it to ''username''.pub
This will create a file called ~/.ssh/id_rsa with your private key and ~/.ssh/id_rsa.pub with your public key. Copy the public key to some convenient location, then rename it to ''username''.pub


  cp ~/.ssh/id_rsa.pub ~/jgeorge.pub
  cp ~/.ssh/id_rsa.pub ~/my_name.pub


Of course, use your own user name here. It is not necessary to use exactly the same user name as your local login, but it helps us distinguish one key from another.
Of course, use your own user name here. It is not necessary to use exactly the same user name as your local login, but it helps us distinguish one key from another.


==Creating an account==
==Creating an account==
Next, you can then email the public key file to David Brunkow or Jim George, and we will add you to the list of git users. Please include a short description of why you want access to the repository as well. You can obtain email information from the [[Contacts]] page.
Next, you can email the public key file to [mailto:git-request@chill.colostate.edu?subject=%5bgit%5d%20Account%20Request Git Request]. Please include a short description of why you want access to the repository as well.


==Getting Started on your machine==
==Getting Started on your machine==
Line 32: Line 34:
         Port 20789
         Port 20789


With git, you have your own git repository on your local machine. This is basically just a directory called cdp (assume repository name is cdp) where you develop the software. The version tracking information is stored in hidden directories within cdp. CSU-CHILL remote git repositories are kept on host lab.chill.colostate.edu.  Your first move is to 'clone' the remote repository on your local machine.  If you already have a directory with the same name as the repository, you should rename it as something else.  When you enter the command:
With git, you have your own git repository on your local machine. This is a directory called cdp (assume repository name is cdp) where you develop the software. The version tracking information is stored in hidden directories within cdp.Your first move is to 'clone' the CHILL repository on your local machine, using the command:


  git clone gitosis@git.chill.colostate.edu:cdp.git
  git clone gitosis@git.chill.colostate.edu:cdp.git
Line 39: Line 41:


==Routine Usage==
==Routine Usage==
The gitolite server manages authorization of who gets access to what repository. To query the list of repositories one has access to, one can give
ssh gitosis@git.chill.colostate.edu info
Since it's possible that others are uploading files to the remote repository, it's a good idea to do a:
Since it's possible that others are uploading files to the remote repository, it's a good idea to do a:


  git pull
  git pull


before you start working with the cdp code to assure that your local repository is up to date. Your typical workflow would be to edit, compile, debug programs in your cdp directories. You can do commits to your local repository as often as you want to track the changes you are making to the files. To do a commit, you first 'add' all files that have changed, the do a 'commit'.
before you start working with the cdp code to assure that your local repository is up to date. Your typical workflow would be to edit, compile, debug programs in your cdp directories. You can do commits to your local repository as often as you want to track the changes you are making to the files. To do a commit, you first 'add' all files that have changed, then do a 'commit'.


So for example, say you modify hyid.c, config.h, generic_kdp_yw.c,  you would commit these changes to your local repository with:
So for example, say you modify hyid.c, config.h, generic_kdp_yw.c,  you would commit these changes to your local repository with:
Line 50: Line 56:
  git commit
  git commit


-- git commit brings up the vi editor, shows you what files you're committing, also shows what files have changed. You are expected to insert comments at the top of the file, documenting what changes were made. Then when you write your comments out and exit vi, and the commit will be completed.  If you quit vi without writing your comments, the commit will be aborted.
git commit brings up a text editor (vi, by default), shows you what files you're committing, also shows what files have changed. You can insert comments documenting what changes were made. Save and exit from the editor (:wq in vi) to complete the commit, or exit without saving changes to abort without committing.


Doing these commits to your local repository is a good way to track changes you make to the files.  It might be useful to do a commit at the end of each day you work on the project.  When you are ready to send a new working version to the remote repository on lab, you just do a push command:
When you are ready to send a new working version to the remote repository on lab, you do a push command:


  git push
  git push


This will merge your changes into the remote repository.
This will merge your changes into the remote repository. This will only work if write permissions are enabled.


If git detects conflicts merging in the changes on a pull or push, which it cannot resolve, it will tell you what files had problems.  You then need to edit those files, look for the conflicts which will be flagged by a <<<<<< or >>>>>, and resolve them yourself.
If git detects conflicts merging in the changes on a pull or push, which it cannot resolve, it will tell you what files had problems.  You then need to edit those files, look for the conflicts which will be flagged by a <<<<<< or >>>>>, and resolve them yourself.


These are the basics.  There is also much git documentation online to refer to.
More information about git may be found in the [http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html git tutorial].
 
Information about git may be found in the [http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html git tutorial].


==External Links==
==External Links==
===References===
===References===
<references />
<references />

Latest revision as of 11:54, 22 February 2016

The CHILL facility now uses the distributed version control system, Git.[1][2], we have switched over from using the legacy CVS [3] system.

We maintain a master repository at the CHILL site, which retains the "golden" copy of the code base. Users may clone this repository and work independently, and those with write access can push their changes back to the master repository. In order to comply with CSU IP policy, anonymous access to the git repository is not enabled, you must have an account to use the system.

The following guide to accessing the repository assumes a Linux machine.

Overview

Everyone accesses the repository via ssh as single user called gitosis. User gitosis exists only on our server, and is restricted to do only repository maintenance tasks. Gitosis checks your ssh credentials against your public key which the administrator has stored in a special directory. This way, remote users do not have to have a login account on the server.

Key Generation

We need a ssh public key file from each person who needs read or write access to the repository. You may already have such a file (usually called id_rsa.pub) in your ~/.ssh directory. If not, you can create one on the machine from which you would like to access the CHILL Git repository :

ssh-keygen -t rsa

You will be prompted for a directory (the default .ssh is fine) and a passphrase. A passphrase is optional, but recommended, you'll need to enter it each time you access the remote repository.

It is not necessary to use the RSA cypher, if your system already has a key with a different cypher (such as DSA), that will work too, but the file names will be different. Contact your system administrator.

This will create a file called ~/.ssh/id_rsa with your private key and ~/.ssh/id_rsa.pub with your public key. Copy the public key to some convenient location, then rename it to username.pub

cp ~/.ssh/id_rsa.pub ~/my_name.pub

Of course, use your own user name here. It is not necessary to use exactly the same user name as your local login, but it helps us distinguish one key from another.

Creating an account

Next, you can email the public key file to Git Request. Please include a short description of why you want access to the repository as well.

Getting Started on your machine

On your local machine, you may need to install the git software. You can probably do this easily using yum or apt-get to download and install git.

Next, you need to modify your ssh setup to use a different port when contacting the CHILL servers, this is a security measure. Edit the ~/.ssh/config file. Create one if it doesn't exist, and add the following lines:

Host git.chill.colostate.edu
        Port 20789

With git, you have your own git repository on your local machine. This is a directory called cdp (assume repository name is cdp) where you develop the software. The version tracking information is stored in hidden directories within cdp.Your first move is to 'clone' the CHILL repository on your local machine, using the command:

git clone gitosis@git.chill.colostate.edu:cdp.git

Git will create a directory called cdp in your present working directory, and copy all the files and version information from lab's repository to your cdp directory.

Routine Usage

The gitolite server manages authorization of who gets access to what repository. To query the list of repositories one has access to, one can give

ssh gitosis@git.chill.colostate.edu info

Since it's possible that others are uploading files to the remote repository, it's a good idea to do a:

git pull

before you start working with the cdp code to assure that your local repository is up to date. Your typical workflow would be to edit, compile, debug programs in your cdp directories. You can do commits to your local repository as often as you want to track the changes you are making to the files. To do a commit, you first 'add' all files that have changed, then do a 'commit'.

So for example, say you modify hyid.c, config.h, generic_kdp_yw.c, you would commit these changes to your local repository with:

git add hyid.c config.h generic_kdp_yw.c
git commit

git commit brings up a text editor (vi, by default), shows you what files you're committing, also shows what files have changed. You can insert comments documenting what changes were made. Save and exit from the editor (:wq in vi) to complete the commit, or exit without saving changes to abort without committing.

When you are ready to send a new working version to the remote repository on lab, you do a push command:

git push

This will merge your changes into the remote repository. This will only work if write permissions are enabled.

If git detects conflicts merging in the changes on a pull or push, which it cannot resolve, it will tell you what files had problems. You then need to edit those files, look for the conflicts which will be flagged by a <<<<<< or >>>>>, and resolve them yourself.

More information about git may be found in the git tutorial.

External Links

References