GitRepoTransfer

This script allows users to clone course repositories from the Swarthmore GitHub.

Instructions

Preparation before running the script

First, ssh into a CS machine (as you normally do for labs).

Then, run the following commands to add your ssh-key (this step ensures that you won’t have to type in your ssh-key for every repo):

ssh-agent bash
ssh add

Now set up gh access by running the first command below, and then answering all the questions and generating a Personal Access Token:

$ gh auth login --hostname github.swarthmore.edu
  What is your preferred protocol for Git operations? SSH
  Upload your SSH public key to your GitHub account? Skip
  How would you like to authenticate GitHub CLI? Paste an authentication token
Tip: you can generate a Personal Access Token here https://github.swarthmore.edu/settings/tokens
The minimum required scopes are 'repo', 'read:org'.
  Paste your authentication token: ****************************************
  gh config set -h github.swarthmore.edu git_protocol ssh
  Configured git protocol
  Logged in as csmajor1

In the above, to create the authentication token, you have to go to https://github.swarthmore.edu/settings/tokens and hit the “Generate new token” button, then select the ‘repo’ and ‘raead:org’ options as shown here (and then hit the green Generate button at the bottom).

Running the script

Run the script with the following command:

python3 gitRepoTransfer.py

When prompted for the course repos you want to transfer, enter the repos in the format Course-Semester as shown in your GitHub, separated by spaces. For example:

cs21-f20 cs31-s21 cs35-f21 e27-spring2021

Notice how if you want to transfer repos from an Engineering cross-listed course, the format may be slightly different.

The script will pull all repos of the courses you selected and put them in /local/repos_<username> (on the lab computer you logged into).

The script will then (if you want) zip all repos into one .zip file, located at /local/repos_<username>.zip.

Transfering the zipped file to your local computer

You can use scp to transfer any file from one computer to another. The basic command format is:

scp username@computer:file_you_want local_filename

This command would be run in a terminal on your local laptop or desktop, and would get file_you_want from username@computer and call it local_filename on your laptop/desktop.

For example, if user csmajor1 is running the scp command from her laptop, which is exactly where she wants her .zip file to be transferred to, and the zip file was created on the lab computer cinnamon, then she will run the following command (from her laptop computer):

scp csmajor1@cinnamon.cs.swarthmore.edu:/local/repos_csmajor1.zip repos_csmajor1.zip

That should pull the zip file from cinnamon and put it in the current directory on the laptop.


Back to SwatCS Help Docs