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
$> git init --bare --shared
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]@ucpu0.ug.it.usyd.edu.au/usr/cs1/[username]/gitrepo/INFO3220.git
NOTE: your home directory is ~. To find out the absolute path of your home directory, runpwd
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
congo3.ug.cs.usyd.edu.au/usr/cs1/abcd6112/gitrepo/INFO3220.git
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
congo3.ug.cs.usyd.ed.au
). 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 :
Summary
The following would the workflow when you're working with your remote repository:
- clone (checkout) the remote repository
- git clone ssh://[username]@ucpu0.ug.it.usyd.edu.au/usr/cs1/[username]/gitrepo/INFO3220.git
- create/edit file(s)
- check the status of the local working copy with '
git status
' - check the diff with '
git diff
' - once you finish editing, specify the files to be updated using
- '
git add filename
' or 'git add -u
'
- commit your changes with '
git commit
' - 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