Skip to main content
Chemistry LibreTexts

7.5: Git and GitHub

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    Git is a Versioning Control System you can run on your computer that allows you to back up files, track changes and revert to older versions by creating a Git Repository (Repo). Within Git you can add your files to a staging area and once you are ready you can commit them to the local repository (Repo), which is in a hidden .git folder.  This creates a hash string to identify each version and allows you to access them later, and compare versions.  You can also push them to a remote repository, of which GitHub is the most common, and the one we will be using in this class.  Figure \(\PageIndex{1}\) is a shematic showing this interaction.

    clipboard_ea2c6903df6d5992652de764f56e735f7.pngFigure \(\PageIndex{1}\): Overview of Git/GitHub integration. (Belford; CC-BY)

    If you wish to use Git you will need to install it on your computer, and if you wish to post material to GitHub or sync your local Git repo with GitHub you will need to create an account on GitHub, but you can access files and download content from a public GitHub without having an account, and we will be posting code at the following GitHub repo,


    To install Git go to and install the appropriate version for your operating system. As always, you can surf the web for tutorials and YouTube if a useful place to find them, but be aware that Git, like any software, is always being updated and so the interface will evolve over time.  There are three common ways to use Git, on the command line, through an integrated IDE (Interactive Development Environment) like Visual Studio or PyCharm, or through GitHub Desktop.

    To install Git go to the downloads page ( ) and install for your operating system.  To see what version you have go to the command line and type

    git --version


    GitHub Desktop

    GitHub Desktop is ideal for students who are not used to the command line and one of the things I like about it is that itallows you to open any local Git Repository to Visual Studio, Windows Explorer and GitHub.  The following YouTubes are pretty good; (Deborah Kurata (Clips 10-13) and Cameron McKenzie, but go out and find your own tutorials and if you find you like you can make a annotation using the tags physical-computing and github-desktop, and I can add them to the site later.

    clipboard_e89b6f51f95bc06f06aabd72b52bb61b9.pngFigure \(\PageIndex{2}\): GitHub desktop allows you to open any Git Repo in VS Code, Explorer or GitHub through an intuitive GUI. (Belford CC 0.0)

    Please note, this is just an introduction to GitHub Desktop and further information can be found in the GitHub Desktop section of the IOST library.

    Visual Studio

    Like GitHub Desktop we have a section of the IOST library devoted to Visual Studio, which is an IDE you should install for multiple reasons.  Once again you should explore the web, look for tutorials and post them to using the tags phys-comp and vs-code.  Note, on VD-code you can install Git-Bash on the terminal and run command line commands from VS-code. The advantage is that it allows you to use Linux commands on a Windows machine, and so the command line commands you need to run your Raspberry Pi will also work here.  See Using Git in VS Code (Official Beginner Tutorial).

    Command Line

    We are probably not going to be using the command line very much as this is an introductory class, but a quick view of the commands may also be the best way to understand Git and GitHub.  I am also including common commands here as a reference point, because as you gain skills you will want to use the command line.

    command syntax function
    git init creates a hidden .git file and transforms current directory into a git working directory, note, do not nest these.
    git add <filename> places the current file into the staging area so you can commit it (this step is skipped in GitHub Desktop)
    git add . the dot allows you to move all files from working directory to staging area
    git status tells status of staging area
    git commit -m"message" commits files from staging area to repo - you need to add a message
    git log see commits
    git checkout <filename> moves file from local Repo to working directory
    git remote add <name> <url> creates remote repo (on github defined by url), typically use <name> as "origin"  
    git push -u origin main pushes local repo to remote using -u switch and sets as main branch
    touch .gitignore creates the git ignore file that allows you to specify files not to be synced with remote see github for gitignore
    git clone <url> clones remote to your machine
    git branch <branch-name> creates a branch (you need to do this if you want to clone someone elses stuff)
    git branch shows you branches





    7.5: Git and GitHub is shared under a not declared license and was authored, remixed, and/or curated by LibreTexts.

    • Was this article helpful?