CS615 -- System Administration

Using git(1)


Learning to use a code revision system and collaborating with others is an important aspect of programming and system administration. Git is a popular free and open source distributed version control system and well worth knowing at least the fundamental of.

Note: git(1) can be used without and independent of GitHub -- please see this online reference! In this class, we will use git(1) for your course notes, although you are of course free to also use git(1) for any other assignments.

You can create a repository on any Unix system you have access to, or even use a public repository such as on GitHub, but your easiest and recommended course of action is to create a repository on linux-lab.cs.stevens.edu.

Working with git on linux-lab.cs.stevens.edu

Create a new repository
$ ssh linux-lab
linux-lab$ mkdir .cs615.git
linux-lab$ cd .cs615.git
linux-lab$ git init --bare
Initialized empty Git repository in /home/jschauma/.cs615.git/
linux-lab$ cd ..
linux-lab$ git clone ~/.cs615.git cs615
Cloning into 'cs615'...
warning: You appear to have cloned an empty repository.
linux-lab$ cd cs615
linux-lab$ vi README
linux-lab$ git add README
linux-lab$ git commit -m 'initialize CS615 repository'
 1 file changed, 1 insertion(+)
 create mode 100644 README
linux-lab$ git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 224 bytes | 0 bytes/s,
Total 3 (delta 0), reused 0 (delta 0)
To /home/jschauma/.cs615.git
 * [new branch]      master -> master

Note: you now have a working directory in ~/cs615, and the bare git repository in ~/.cs615.git. You should never have a need to enter or access files in the bare git repository other than via the git(1) client.

Working in your repository from another system

$ git clone linux-lab.cs.stevens.edu:.cs615.git cs615
Cloning into 'cs615'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
$ cd cs615
$ git commit README 
[master 05b7bd1] asd
 1 file changed, 1 insertion(+)
$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 240 bytes | 240.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To linux-lab.cs.stevens.edu:.cs615.git
   699425a..05b7bd1  master -> master

Working with git

You should make it a habit to begin your working session by updating your copy of the repository and ending it by committing your changes. If you are ready to push your changes, you would then push them to the repository:

$ cd group1
$ git pull
$ $EDITOR notes
$ git commit
$ git push

Please always write a meaningful commit message. See these links for why/how:

[Course Website]