Skip to content

Git workflow for tutorials

Friedrich Knuth edited this page Jun 21, 2019 · 9 revisions

Basic workflow to follow along with tutorials and save changes to your fork, while staying up to date with any changes made to the master tutorial.

Step 1

Fork the tutorial repository via the GitHub web user interface.

For example, https://github.com/friedrichknuth/geospatial-analysis forked from https://github.com/ICESAT-2HackWeek/geospatial-analysis .

Step 2

Clone the forked tutorial to your machine.

$ git clone https://github.com/friedrichknuth/geospatial-analysis.git
$ cd geospatial-analysis  

Step 3

Add the upstream master so we can stay up to date with any changes made to the main tutorial.

$ git remote add upstream https://github.com/ICESAT-2HackWeek/geospatial-analysis.git

Step 4

Fetch and merge the latest changes from upstream master.

$ git fetch upstream
$ git merge upstream/master

Step 5

Checkout a branch to make changes and follow along with the tutorial.

$ git checkout -b branch_name  

Step 6

Follow along and make changes. Then commit your changes and push them up to your fork, under your branch.

$ git commit -am "Make changes"  
$ git push origin branch_name  

Now your fork will have your changes backed up to GitHub under your branch.

If additional changes were made to the upstream master tutorial, you can checkout the master branch $ git checkout master and repeat step 4 to get the latest content, then checkout a new branch with a different name and follow along from there.


Adapted from https://medium.com/sweetmeat/how-to-keep-a-downstream-git-repository-current-with-upstream-repository-changes-10b76fad6d97

Clone this wiki locally