Skip to content

github forking and python assessment

Forking on GitHub

Go to the following GitHub URL https://github.com/hackers-test/hack-5-python.git and click on Fork button in the far upper right corner. This will take a few seconds to create a copy and then a new repo will be created under your profile that includes a clone of this repo.

So what is a fork, and how is it different from a clone? Like cloning forking creates an identical copy of a repository, but the difference is that the remote is located under your profile (your ownership permissions) rather than the person's who you forked it from. This means that you will have permission to push changes to the remote without needing that users permission.

When should I clone versus fork

If you do not plan on editing the code and contributing your changes back to the remote, then you can simply clone a repo. This simply downloads a copy of the source code onto your computer that you can use or edit locally for testing. This is a common way to test out software that is on GitHub. But, if you want to make changes and propose these changes to the owner of the repo through a pull request, then you need to create a separate fork. Forking is a GitHub thing, having to do with permissions for writing to a specific GitHub remote.

How we will use forking for class

In this class I will occasionally ask you to fork a repo so that you will have your own copy of it in your GitHub account. You will then be asked to edit the repo -- for example, open the notebooks in the repo and complete them -- and will be graded on the changes that you make and push back to your remote repo on GitHub.

A test push

Before you move on to your assignment, let's first do a test by pushing a change to your new forked repository. Let's make a change to the README file, then use the simple git workflow to push these changes to the remote. From your version of hack-5-python on GitHub click on the clone button to get the link and run the command below to clone the repo to your local computer.

# clone your fork of the hack-5-python repo into your hacks folder
cd ~/hacks/
git clone {paste the repo URL here}

# add some text to the README file
cd ./hacks/hack-5-python
echo "\nThis repo contains several jupyter notebooks" > README.md
git add README.md
git commit -m "added text to the readme"
git push origin main

You can now go look at your fork on GitHub and see that your changes have appeared.

Assessment

Success

You will be graded based on completion of the instructions below, where the final product will be found on your GitHub profile.

  1. Fork the hack-5-python repo above (you already did this above).

  2. Clone your copy of hack-5-python (you already did this above).

  3. Start a jupyter notebook server from your home folder

  4. Open your browser to localhost:8888 and look in the hacks/hack-5-python/notebooks directory. Here you will find several notebooks. Complete them in order by following the instructions inside each notebook. Be sure to save the notebooks when you are done (it auto-saves also, BTW), by pressing the save button in the menu bar.

  5. Stop your notebook server.

  6. From your terminal sync the changes you've made to these notebook using the git command line tool following the add, commit, push, workflow that you learned in the last session. Be sure to cd into the hack-5-python directory to do this.