Getting Started with Julia and GitHub


Lab 01

August 25, 2023

Using GitHub and Lab 1

Overview

Labs are in-class exercises intended to get practice with coding or analysis workflows.

  • Instructions available on website
  • Download ahead of time by using link in Ed Discussion.
  • Will have your own repository — let’s discuss how to use it.
  • Don’t have to finish these in class, but due by the end of next week (Friday, 9/1, 9pm).

Using GitHub: Cloning

GitHub Workflow

  • “clone” repositories on GitHub (remote → local).
  • “commit” and “push” changes (local → remote)

Clone Repositories: GitHub

  1. Once you have created your account, navigate to the GitHub repository for the assignment.

  2. Click the green “Code” button, and copy the URL by clicking on the clipboard icon.

Code Clone Interface on GitHub

Clone Repositories: VS Code

  1. Open a new VS Code window.
  2. Click “Clone Git Repository”.
  3. Paste the URL you copied from GitHub into the search bar and select the repository, then pick a location to save.

VS Code New Window

Using Local Repositories

  1. You will be prompted to open the new folder.
  2. The next step you open VS Code, pick “Open Folder” from the initial New Window page.

Open Folders, Not Files

Opening a folder is recommended because it gives you access to a wider set of tools and the version control interface.

Jupyter Notebooks

Notebooks Consist of Cells

Jupyter notebooks consist of two cell types:

  • “Text” cells, which use Markdown and LaTeX syntax for text and math.
  • “Code” cells, which contain code which can be evaluated (in this case Julia).

Notebook Kernels

You need to pick a kernel to tell Jupyter what language and version to use for code evaluation.

After pressing the kernel selection button (right):

Kernel Selection Button
  1. Select “Select Another Kernel”.
  2. “Julia Language Support”
  3. “Julia 1.9 Channel”

Editing Notebook Cells

  1. Double click the text cell at the top of the notebook that includes the “Name:” and “ID:” prompts. Add your name and Cornell NetID.
  2. Create a new cell by hovering your cursor over the bottom of a cell. You should see the buttons on the bottom right pop up.

Click on “+Code” or “+Markdown” and the new cell should appear.

Create New Cell

Using GitHub: Committing

Committing Changes

“Committing” is the git term for locking in a particular repository state.

  • Once changes are committed, you can restore that version of the files by reverting later changes.
  • Commits are associated with messages which briefly describe the change(s) that were made.
  • Commit meaningful changes often and use informative messages!

VS Code and Git

You will see the icon on the right on the left-most (vertical) bar. This is the “Source Control” icon.

VS Code Source Control Icon

Click this and the “Explorer” panel will change to the “Source Control” panel.

Click the “+” button next to any files you want to commit, add a message, and click “Commit”.

Pushing Changes

“Pushing” syncs committed changes from the local repository to the remote repository on GitHub.

  • Once commits are pushed, they can be viewed on the repository by anyone with access.
  • Your repositories are all public, so your classmates, the TA, and I can see your code and try to help debug!

Pushing and VS Code

Once you’ve made commits, you will see the following on the bottom of your VS Code window:

  • The number by : # of remote commits which are not present locally.
  • The number by : # of local commits which have not been synchronized.

VS Code Sync

Click the button and VS Code will “pull” remote changes and “push” local changes.

Exporting Notebooks

Exporting Your Notebook to PDF

You’ll need to export your notebook to a PDF to submit to Gradescope.

You should see the following menu bar at the top of the VS Code window: Notebook Menu Bar

Export Steps

  1. Click “Run All” to execute all cells in order.
  2. Click the ellipsis (“…”) and select “Export”, then click “HTML”.
  3. Save the file, then when prompted open it (should open in your browser).
  4. Go to the print interface and save as a PDF.

Upcoming Schedule

Next Classes

Monday: Modeling Systems

Wednesday/Friday: Examples of Systems Models