Working Locally
For some of our classes at Tower Hill, you will move from the cloud and begin working on your own machine. This page is an attempt to help you with that process.
Github
You should already have a Github account from other classes. Be sure you know how to login to that.
SSH
The git repos for your assignmnets will be private and you will need to authenticate in order to clone them and write to them. The most convenient way to do that is to use an SSH key. If you already have one, just add your public key to Github at https://github.com/settings/ssh/new
If you need to create one, you can follow the instructions for creating one and testing it for your operating system. Github has very extensive help at https://docs.github.com/en/authentication/connecting-to-github-with-ssh
Your Development Environment
A Place for Your Work
I recommend creating a folder for your CS work. For my example, I’m going to put it in my home folder and call it s_work which I can do using the following commands at the terminal.
cd
mkdir cs_work
A Python Virtual Environment
For my example, I am going to call it ai
which I can do with the following commands:
cd
cd cs_work
python -m venv ai
To activate that environment, I’ll use the command:
. ~/cs_work/ai/bin/activate
To deactivate, I can just type deactivate
and press return.
Working On A Programming Problem
Cloning Your Repo
The first thing you’ll need to do after accepting the assignment on Github Classroom is to clone your repo for the assignment. Go the page on Github for your repo, copy the SSH URL for it and issue the following commands (this is all based on my example above, adjust for your directory names):
cd
cd cs_work/ai
git clone url_for_repo
where url_for_repo
is the SSH URL for your repo.
Working On The Code
My suggestion is to find the folder for the repo using the GUI file manager for your OS (Finder, Explorer, whatever). Then drag that folder onto VS Code and it should launch as a project.
In the terminal in VS Code, type the following command and press return:
. ../bin/activate
Make your edits, commit often, push when you’re done for the day.
Using Git
You will learn how to use Git well with practice and we will talk about how to do this properly over time. For now, it’s okay to try your best. Let’s use an example.
Assume your repo is a website project and you want to complete two tasks for your homework:
- Add a dropdown to the home page
- Add a new page and include it in the menu
You might do something like this:
- Edit
index.html
to include the dropdown - Edit
styles.css
to style that dropdown - Edit
script.js
to add functionality to that dropdown
When you’re done, you should commit these changes.
Start by staging your changes:
git add index.html styles.css script.js
Then commit those changes:
git commit -m "Add dropdown to home page"
Then move on to task number two:
- Create a new page - called
newpage.html
- Add content to that page
- Edit
index.html
to includde the new page in the navigation menu.
Stage your changes:
git add index.html newpage.html
Commit your changes:
git commit -m "Add new page"
Now that you’re done for the day, you can (and probably should) push your changes to Github (so you or your collaborators have a copy and your teacher can see your work).
git push