Git Quick Guide

Our lab uses gitlab.com to host most of the project source codes in private repositories. Here are very quick guides from without git knowledge. Note there is no difference in use of gitlab or github. You use the same software system, except you specify different repo in the url.

Install Git in Windows

  1. Create an account at gitlab.com if you haven’t.
  2. Install Git for Windows.
  3. Add user. See “Configure Git” in this webpage: https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html.
  4. Add SSH key to your gitlab profile. Follow this guide: https://docs.gitlab.com/ee/ssh/.
  5. Now you can right click in any folder and select “Git Bash Here” to use git in this folder

Clone Project

  1. Go to the project page on gitlab.com.
  2. Click the blue “Clone” button.
  3. Copy the “Clone with SSH” link, e.g. git@gitlab.com:ailabuser/example.git.
  4. Navigate to the root of your workspace folder in your computer. The cloned project will be a sub folder in here. This workspace can have your different projects in different sub-folders.
  5. Right click and select “Git Bash Here”.
  6. Enter git clone followed by the project SSH link, e.g. git clone git@gitlab.com:ailabuser/example.git.
  7. You should see the project being downloaded to your computer.
  8. May be helpful: https://stackoverflow.com/questions/30202642/how-can-i-clone-a-private-gitlab-repository

Useful References

  1. Workflow: https://rogerdudler.github.io/git-guide/
  2. Tutorial: https://www.git-scm.com/docs/gittutorial/1.8.2
  3. Each time you want to push your changes:
    • Add new files to git: git add filename or git add *.
    • Commit changes to git: git commit -m "Commit message".
    • Push changes to remote: git push origin master or simply git push if you are not working with branches.
  4. Other useful commands:
    • To check all branches local and remote: git branch -a.
    • To pull changes from remote: git pull.
  5. Below are the slides prepared by Amran:

    Download (PDF, 378KB)