ViSLAB now support the use of git for version controlling your project. This page describes the basic use of git to manage your project. BackgroundViSLAB's project server project.vislab.usyd.edu.au has git installed. You can create a git repository in your own directory but this document also describe how to create shareable repository.ConfigBefore start using git, configure your own environment. First setup your username and email address, which will be used when you commit your code: $ git config --global user.name "yourusername" $ git config --global user.email "your@email.address" You can also set the colour setting so that the out can be easily read. $ git config --global color.ui auto $HOME/.gitconfig file. It should now look like:When you working on a project, you might end up creating files, which do not need to be version controlled. For example, backup files automatically generated by your editors, some intermediate files, which can always be re-generated from your main files. You can specify the rules, which describes what sort of files should be ignored by git command. You can have ' .gitignore ' file in your local working directory but you can also have .gitignore file in your home directory and register it as your global ignore rules.Say, you have created the following " .gitignore " file in your home directory.$ cat ~/.gitignore *~ *.o *.lo *.la .*~ .DS_Store $ $ git config --global core.excludesfile ~/.gitignore Creating Local RepositoryThis section describes creating a local git repository and manage your files locally. First we create a directory called myProject .$ mkdir myProject $ cd myProject $ git init This command will create a .git directory in myProject . This .git directory is your local repository. Now we will add our first file to be controlled:$ touch README At this stage README file is not under git's control. If you type git status , you will get:$ git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track) This indicates that README is not tracked by git.$ git add . $ git commit -m "Initial commit" SummaryThe following would the workflow when you're working with your local repository:
Working with Remote RepositoryThis section describes how you could work with the remote repository. First, once you have decided the name of your project, which to be hosted on project.vislab.usyd.edu.au , ask ViSLAB admin to create the project directory on the Group folder. Then ViSLAB admin will create an empty git repository for you.Creating shared remote repositoryThis is done by ViSLAB admin (on project.vislab.usyd.edu.au ): (we assume that the new group has created and you're added to that group)$ cd /Groups $ sudo mkdir newGroupName ; cd newGroupName $ sudo mkdir newProjectName.git ; cd newProjectName.git $ sudo git init --bare --shared $ cd .. $ sudo chgrp -R newGroupName newProjectName.git Create files locally and commit to the remote repositoryFist you can clone (checkout) the empty repo from the remote repository: me% git clone ssh://project.vislab.usyd.edu.au/Groups/ newGroupName / newProjectName.git Then you can add a file: me% emacs README me% git add . Then you can commit your changes to your LOCAL repository. me% git commit -m "Added my comment" project.vislab.usyd.edu.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:me% git push origin master me% git pull SummaryThe following would the workflow when you're working with your remote repository:
Useful commandsgit tagYou can tag your commit. The following command will assign the specified tag to the commit just executed: $ git tag tagname Generating RSS Feed |
Resources > Standard Procedures >