Quick and Dirty Introduction to Git for MATH 351
Say you’ve got a URL to one of our GitHub worksheet repositories, e.g. https://github.com/ChicoStateMATH351Spring25/homework-02-roualdes. You should have access to such a private repository for each specific assignment within your GitHub account. Submitting an assignment will generally follow these steps: copy the assingment from the GitHub repository, edit files, and push the files back up to the assignment’s repository. I will then grade your assignment from your repository.
With a working installation of git on your machine, you will
generally follow these steps from within a (git
)
bash terminal where
$ git --version
successfully returns a version number for git and specifically with no error message.
$ cd ~/...wherever.../math351/homework/
clone
clone
– copy the assignment to your machine
This will copy the entire repository (directory on GitHub) to
your current working directory $ pwd
. Be sure you’re in a
reasonable directory before executing the below command.
$ git clone https://github.com/ChicoStateMATH351Spring25/homework-02-roualdes.git
edit
edit - do the assignment as appropriate
Since all worksheets assignments are turned in as Jupyter Notebook documents, open a notebook file within your current working dirctory, then edit the file. You will submit the notebook.
status
status
- check the status of local git directory
If you editted any files, notice that all added or
edited files are now marked as modified and/or not
tracked. Pushing edits to a repository is a three step
process: add
, commit
, push
.
We will execute the following status check after each step to
help us learn Git as we go, but generally you can just add
,
commit
, and push
with nothing in between, when you are comfortable with this.
$ git status
add
add
- stage your added/modified files
For reasons we won’t explain in this class, before you can
finalize your edits we must stage the files we wish to
push. Assume you want to submit the file hw.ipynb
.
To stage this file execute
$ git add hw.ipynb
You can identify more files to add
by separating the file
names with spaces.
Check the status again after add
ing file(s).
commit
commit
- confirm the added changes
Commiting some changes to your local git directory is the
formal way to lock in add
ed changes (locally).
$ git commit -m "a short message describing the edits goes here in quotes"
Just for learning, check the status after commit
ing
file(s).
push
push
- send the commit
ed changes to the remote repository
push
ing to your remote repository (the one I can see on
GitHub) is the formal way to lock in commit
d
changes (remotely).
$ git push
You can confirm that your worksheets was properly submit by
viewing the GitHub repository online. The repository we’ve
been working with is located at
https://github.com/ChicoStateMATH351Spring25/homework-02-roualdes
,
which you won’t be able to see because it’s private. It’s
highlighted here so you can see that it’s nearly the same link
as the one we cloned from.