Resources‎ > ‎Programming‎ > ‎C++‎ > ‎C++ Tutorial‎ > ‎Lesson 1‎ > ‎


Create the main git repository database on a server

Create the repository

  • log into SIT's ssh server.
  • Create a directory to store your git repositories
$> mkdir ~/gitrepo
  • create a directory to store your repository
$> mkdir ~/gitrepo/INFO3220.git; cd ~/gitrepo/INFO3220.git
  • create a repository
$> git init --bare --shared

For GUI users...

Clone (checkout from) your repository 

  • on your computer (your notebook, desktop PC or PC in the SIT lab....not the SIT's server)
  • Or in the different directory on the SIT machine
  • Don't forget to replace "[ username ]" to your UniKey
$> git clone ssh://[username][username]/gitrepo/INFO3220.git

NOTE: your home directory is ~.  To find out the absolute path of your home directory, run
$> cd~ ; pwd
pwd shows the absolute path to the current directory.  For instance, if pwd shows /usr/cs1/abcd6112, then your git repository for, say, INFO3220.git will be

Create/modify files locally and commit to the remote repository

Once you clone the repository on your local machine, you can add/modify files:
$> vi README.txt
$> git add .
Then you can commit your changes to your LOCAL (cloned) repository.  (Hence, you can keep using the versioning system even if you're not online.)
$> git commit -m "Added my README file"
At this stage, your commit is not on the remote repository (on  In order to reflect your commit on the remote repository so that other people can clone your changes, you need to push your local repository changes to the remote master:

$> git push origin master

If your group members changed something on the remote repository, you can get the new changes and merge into your local repository by :
$> git pull


The following would the workflow when you're working with your remote repository:
  1. clone (checkout) the remote repository
    • git clone ssh://[username][username]/gitrepo/INFO3220.git
  1. create/edit file(s)
  2. check the status of the local working copy with 'git status'
  3. check the diff with 'git diff'
  4. once you finish editing, specify the files to be updated using
    • 'git add filename' or 'git add -u'
  5. commit your changes with 'git commit'
  6. propagate your commit to the remote repository with 'git push origin master'

Useful commands

git tag

You can tag your commit.  The following command will assign the specified tag to the commit just executed:
$ git tag tagname