Git Repository

From Computer Science Community

Revision as of 07:33, 15 January 2011 by Puffy (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

[edit] What is Git?

Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server. Branching and merging are fast and easy to do.


Notable projects using Git include:

To view CSC's public repository website, check out this site:


[edit] Installing Git

Installing git is a pretty simple job for linux users as usually each distribution has a version updated in their software repository. If not, or you are running windows, you can download a version here:

[edit] Using Git

This section is meant to cover the very basic information of git commands and use. This section is not supposed to be a full reference. For a full reference, please look here:

[edit] Downloading other people's code

$ git clone git://

Running this command after git is installed will make a direct copy of the project's repository, the equivalent of a local fork or downloading all the source code directly with the advantage of being able to update the codebase with one command.

[edit] Updating your clone's codebase

$ git pull origin master

Running this command will update your local codebase to the most current revision on the developer's master branch.

[edit] Setting up a local repository

Setting up your own private repository is easy and very useful when dealing with projects or debugging code or for testing different revisions of your code. Here's the general command listing of how to setup and keep track of changes in your codebase:

$ cd my_proj
$ git init
$ git add .
$ git commit -am "Initial commit"

For a single developer, one would probably only really use this set of commands:

$ git add file
Adds "file" to the repository in the current working directory (file must exist). One may also use "." for the current working directory and all those below it.
$ git rm file
Removes/deletes "file" from the repository in the current working directory (file must exist). This is confusing, as you cannot delete it normally (IE: rm -rf file) as the changes will not reflect in your repository and if you were to update your codebase, you would receive the file again.
$ git commit -am \
"A very verbose message explaining what changed and why"
Saves and logs all the changes made to files currently added to the repository.
$ git push origin master
Pushes all commits to a remote repository aliased by "origin" on branch "master".

[edit] CSC's public repository

This is CSC's public repository, listing all projects worked on or currently being worked on and are publicly available for anyone to download or submit their own. Creating a project requires two things:

  • A project name
  • A public/private rsa key pair

There are several ways to generate the pair for different operating systems. This section will concentrate on the linux side of things.

$ ssh-keygen -t rsa
Using this command requires that you have openssl and openssh installed. It is a good security measure to password protect your keys, as without the protection, others that have access to your files will be able to spoof themselves as you. In order to use your keys, the permissions to those files must be as follows:
chmod 700 ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_rsa
Now create the file ~/.ssh/config if it doesn't already exist and append the following:
    Port 2200
Follow this link and register yourself as a user and your project following the links provided. Afterwards, you need to add the remote server to your initialized codebase:
$ git remote add alias
Where "alias" is whatever you want to call the remote repository when using git push (normally "origin") and "my_proj" is your project name.

[edit] Other Public Repositories

[edit] See Also

Personal tools