Git - magudelo/SystemsControlTheory GitHub Wiki
Note: This wiki was originally written by Arnaud Installe and Marc Claessen.
Git
is a version control system. Using git
allows to keep track of the changes in your project. This can be useful for several reasons, for example to compare with earlier versions.
More specifically, git
is a distributed version control system. This means that, rather than a centralized server keeping a copy of the entire project's history, with clients only having the latest version, everyone keeps a full copy of the entire project's history. Technically, all copies are equivalent. However, by convention, one copy gets assigned the role of "master" copy. For the current project, the master copy is the one on github.
You can copy the 'SystemsControlTheory' repository to your own machine with the following shell command:
git clone https://github.com/magudelo/SystemsControlTheory.git
(NOTE: If you have information on how to do this using the git
GUI, please add it.)
With a copy of the repository on your local machine, the typical git
workflow that you will use to change anything will be the following:
- Start by pulling in the most recent version from the repository's master copy, using
git pull
; - Edit files;
- Register changed files with the
git add
command; - Create a new version locally using the
git commit
command; - Push the new version that you created locally to the master copy, using the
git push
command.
You should go through these steps for every change you want to apply. Ideally, these changes should be as small as possible, while still logically belonging together.
The following are the most important commands you will use:
-
Registering files:
If you have created a new file that should be tracked bygit
, or you have changed a file thatgit
is already tracking, you should register it with the following command:
git add <file>
-
Obtaining the status of your repository:
The following will show a list of files that have been changed, but have not yet been registered, as well as a list of files that have been changed, and have already been registered:
git status
-
Committing a version to the repository:
By "registering" files (using thegit add
command), you only enter them in the "working copy" of the repository. To really create a new version, you use the following command:
git commit
-
Copying your changes to the github master repository:
You can save your changes to the master repository with the following command:
git push
-
Copying changes on the github master repository to your local machine:
You can copy changes that your colleagues submitted to the master repository to your local machine with the following command:
git pull
More information about git
can be found on http://git-scm.com/doc.
git
has a graphical user interface, which has equivalents for all of the above commands. This should be self-explanatory. You can download a Desktop client (available for Windows and Mac) from the following link: https://desktop.github.com/.
The git push
command normally will ask you to log in every time. This can be tedious. You can simplify this by using ssh
keys. To enable this, you should follow this procedure.
Conflicts can arise when you use the commands git pull
or git push
. This happens whenever you and one of your colleagues have made changes to the same file. In such cases, the git pull
and git push
commands will display an error message. Such events should be rare, as we will avoid having people simultaneously working on the same file. If you do encounter such a problem, please notify one of the teaching assistants, and we will help you resolve the conflict.