hw17: Class-wide git repo
- Due before the beginning of class on Wednesday, February 21
Overview
This unit is based on the current unit and will be sort of a follow-on to the previous homework on using GitHub.
There are two parts. First, you will install a pip
package
special for this class that will tell you a “secret” phrase just for you.
Second, you will edit some code in a git repo that is shared across the
entire course, where the part that you should edit corresponds to your
“codename”.
Pip package to find your secret phrase
We made a pip package just for this assignment!
Here are its pages on github and on pip
To install it, run these two commands in your terminal:
mamba activate sd212
pip install rand-wordpair
Now you have to find your personal secret phrase.
To do that, you just need to use Python to
run the show_user_code()
function from the rand_wordpair
package.
Take note of your “secret” phrase. You will need it for the next part!
Class-wide shared git repo
For this assignment, you will all join in one big class-wide git repo.
If you completed the previous homework by the end of the day it’s due, you will be added as a collaborator on the shared public repo at https://github.com/sd212usna/share24.
If you don’t see an invite (like if you didn’t complete that homework or submitted it late or put the wrong github username), then send your instructor an email and they can add you, no problem.
Then follow these steps:
Get the SSH link for the shared repo
Open the shared repo page on github
Click the green Code box, select the SSH option, and copy the line that starts with
git@github.com:
to your clipboard
Clone the repo to a local directory
Open a terminal in your sd212 folder (not inside your other repo for lab 7!)
Clone the shared repo by running:
git clone git@github.com:...
where the last part is what you pasted from the clipboard
Check that this downloaded and created a new folder called
share24
Modify a file
Find the
secX.py
file corresponding to your section, and follow the instructions there to add some code to YOUR function (only!).You will need to add your code to the function corresponding to your own personal “secret” phrase from the first part above.
Save and run the
secX.py
file to see if it’s working. Do not edit other people’s code. Be careful you don’t introduce a bug which makes it not work!Create a new file
Add a new file in the folder
secXfiles
for your section with filenamem260000.txt
but using your actual alpha of course.You can put anything you want in the text file. I recommend some tasteful ASCII art.
Commit the two changes that you just made to the local copy.
In the terminal, use
cd
to go to the foldershare24
Run
git add
for your new file, likegit add secX/mYYYYYY.txt
Commit both changes by running
git commit -a -m "MIDN 3/C Jones reporting in"
(Note, the
-a
flag means “all” and will include your changes to the Python file as well as the new file you just added. And of course you can change the message after-m
to anything you want.)
“Push” your commit to the shared repo
In case some other changes were made in the meantime, run
git pull
to update your repo to the most recent version
Not push your commit:
git push origin main
(It might also work if you leave off the
origin
andmain
parts.)Confirm it worked! Go to the shared github page and make sure you see your changes in the Python program as well as the new file you created in the section directory.
Open the github page for the shared repo and double-check that your changes got in.
That’s everything! Make sure to go back and make sure you understand the commands you ran and what they did. Challenge yourself to go back to the repo again the next day and make some more changes to your python function.