Skip to content

Version Control with Git

This page is for information about version control with Git. We use Git to manage and collaborate on any sort of code or coding project, including MATLAB, Julia, C/C++, Python, or anything else you may write that should be managed using version control. We also use Git to collaborate on LaTeX documents (e.g., journal or conference paper submissions). If you are writing code of any sort, you should use Git version control.

GitLab Hosted by Smith Engineering

All code developed by MItHRIL members is required to be stored using a GitLab server hosted by Smith Engineering at Queen's. With GitLab you can easily collaborate with your colleagues, share your code, and manage who sees (or does not see) your work.

Obtaining Access to GitLab

If you have not used Smith Engineering's GitLab before, you must have your access activated by Smith Engineering IT. Request access using the Self-Service IT Portal. Once you have access, you may log in to GitLab using your Queen's NetID and password.

MItHRIL GitLab Group

Unless you have a good reason, your projects should always be created under the MItHRIL group within GitLab. If you create a project under your private workspace, your work for MItHRIL may be lost after you leave Queen's. To join the MItHRIL GitLab group, send an e-mail to Prof. Pan once you have confirmed your access to GitLab.

Issues

If you have any technical issues with using the GitLab service, email help@engineering.queensu.ca.

Git Tips, Tricks, and Resources

  • Git Tutorials: a slide deck from the git tutorial given by Matthew Pan on June 28, 2023, was linked here; re-attach it once migrated.
  • Git Cheat Sheet: GitHub has a nice, comprehensive cheat sheet that you can print out and keep at your desk.
  • Git Book: the Pro Git book, written by Scott Chacon and Ben Straub and published by Apress, is a great resource for beginners and experts alike. Version 2 (2014) is available online for free.
  • Git Branching Models: Atlassian provides a good explanation and comparison of different git branching models and workflows, including the gitflow workflow.

Cloning Large Projects

Some larger projects can result in problems when a new user tries to clone or pull the repository, producing a series of messages like:

fatal: The remote end hung up unexpectedly | X.XX Mb/s
fatal: early EOF
fatal: index-pack failed

If this happens, the following commands (per the accepted answer to a relevant Stack Overflow question) can help:

git config --global http.postBuffer 1048576000
git config --global core.compression 0
git clone --depth 1 <repo_URI>
git fetch --unshallow
git pull --all

Where <repo_URI> is the URI for your particular repository (e.g., http://code.smithengineering.queensu.ca/bl54/matlab-tools.git).

LaTeX Projects

If you have a LaTeX project under version control, do not include output files (e.g., DVI or PDF output) unless you have a good reason. Also avoid committing temporary or other working files, which can take up unnecessary space. Only include what your project needs to compile, to minimize the size of your project.

Updating the Remote Location on Your Local Machine's Repository

Useful instructions in case you need to update the remote location of a repository on your local machine (in the Terminal, replace items in <...> as required):

cd <project_directory>
git remote set-url origin <new_repo_name>