diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..2e78fc3 --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,43 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy static content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: './03_instructional_team/githubpages' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/03_instructional_team/homework/git_homework_2.md b/02_activities/homework/git_advanced.md similarity index 63% rename from 03_instructional_team/homework/git_homework_2.md rename to 02_activities/homework/git_advanced.md index 657edfd..72a126a 100644 --- a/03_instructional_team/homework/git_homework_2.md +++ b/02_activities/homework/git_advanced.md @@ -1,15 +1,12 @@ - +# Git Advanced Homework -# Git Homework 2 - -## Short answer -1. What makes a good Git commit message? Write your answer in the Google Doc +**Note**: Homework problems are not assessed and are provided for your own personal practice. Feel free to discuss these with your peers and learning support during work sessions! ## Tasks -The `DSI/git_homework-2` repository contains a short Python script that +The `dtxe/DSI_git_assignment` repository contains a short Python script that loads the TTC Bus Delay dataset, computes the average delay by route, then plots the average delay as a histogram. - +s 1. Clone this repository: https://github.com/dtxe/DSI_git_assignment * `git clone` @@ -21,7 +18,6 @@ get this code working by merging the fixes. 1. Check the current status and commit history * `git status` and `git log` 2. Merge the `bugfix1` branch into the main branch -3. 📸 Take a screenshot of your terminal output ### Task 2 We've also been working on an additional feature in a separate branch. @@ -30,7 +26,6 @@ This allows us to aggregate the data by any arbitrary column in the DataFrame, n Let's merge this feature in. 1. Merge the `feature1` branch into the main branch. -2. 📸 Take a screenshot of your terminal output ### Task 3 Uh oh! It looks like there's a merge conflict between the bugfix and the new feature! @@ -38,9 +33,5 @@ Uh oh! It looks like there's a merge conflict between the bugfix and the new fea 1. Resolve the merge conflict in your choice of editor * We suggest using VSCode! 2. Complete the merge after fixing the conflict. -3. 📸 Take a screenshot of your terminal output -4. Copy and paste the new Analyze.py file into the Google Doc -## Submission -* Submit your screenshots and the contents of the new Analyze.py file in a Google Doc inside your submission folder diff --git a/02_activities/homework/git_basics.md b/02_activities/homework/git_basics.md new file mode 100644 index 0000000..3f12cff --- /dev/null +++ b/02_activities/homework/git_basics.md @@ -0,0 +1,5 @@ +# Git Basic Practice Problems + +Load the basic practice problems in your browser here: https://uoft-dsi.github.io/git/interactive_problems.html#git_basics + +**Note**: Homework problems are not assessed and are provided for your own personal practice. Feel free to discuss these with your peers and learning support during work sessions! diff --git a/02_activities/homework/git_homework_1.md b/02_activities/homework/git_moderate.md similarity index 62% rename from 02_activities/homework/git_homework_1.md rename to 02_activities/homework/git_moderate.md index 4021721..cb7a808 100644 --- a/02_activities/homework/git_homework_1.md +++ b/02_activities/homework/git_moderate.md @@ -1,4 +1,6 @@ -# Git Homework 1 +# Git Basics + +**Note**: Homework problems are not assessed and are provided for your own personal practice. Feel free to discuss these with your peers and learning support during work sessions! ## Tasks ### Task 1 @@ -8,26 +10,23 @@ 4. Using the git command line, add this file to staging, then commit the file to your repository with a suitable commit message. * `git add ` then `git commit` 5. Write a suitable commit message and finalize your commit -6. 📸 Take a screenshot of your terminal output 8. Show the commit history * `git log` -9. 📸 Take a screenshot of your terminal output + ### Task 2 1. Create a new public repository on GitHub 2. Add your GitHub repository as a remote for your local `githomework1` repository * `git remote add origin ` 3. Push your local `githomework1` repository to GitHub -4. Include your repository URL in your submission + ### Task 3 1. Create a new branch called `playing-with-bash` -2. Create 5 empty files with the names up to you -3. Use `echo` into the 5 empty files a few sentences about anything +2. Create 5 text files with the names up to you, and with placeholder contents 4. Stage, commit and push your work on GitHub 5. Open up a pull request -### Submission - -1. When you are done, please commit your changes, and push it to GitHub. -2. Open up a pull request and add your Learning Support Person as a reviewer. You may need to add them to your repository. +### Task 4 +1. Explore your repository on GitHub and check that all your files and commit messages are here. + * If not, did you push all your branches? diff --git a/03_instructional_team/githubpages/git_basics.yml b/03_instructional_team/githubpages/git_basics.yml new file mode 100644 index 0000000..db1c00c --- /dev/null +++ b/03_instructional_team/githubpages/git_basics.yml @@ -0,0 +1,325 @@ +title: Git Basics Practice Problems +problems: + - title: Git commands + description: | + You're starting a new project called `my_project` and would like your code to be version controlled. + From your home directory, which commands will create a new directory called `my_project` and initialize a new Git repository? + questiontype: parsons + options: + - "`mkdir my_project`" + - "`cd my_project`" + - "`git init`" + - "`git clone`" + - "`git create`" + - "`git add my_project`" + - "`git mkdir my_project`" + correct_options: [0,1,2] + solution: | + To create a new directory and initialize a Git repository, you would use the following commands: + 1. `mkdir my_project` - This creates a new directory called `my_project`. + 2. `cd my_project` - This changes the current working directory to `my_project`. + 3. `git init` - This initializes a new Git repository in the current directory. + + The other commands are either incorrect or not necessary for this task. + + - title: Git commands + description: | + This is your terminal prompt: + ```bash + user@computer:~$ ls + Desktop/ Documents/ Downloads/ Music/ my_project/ Pictures/ Videos/ + user@computer:~$ + ``` + You might have made a change to a file in the `my_project` directory, but you're not sure. + How would you check if your working directory is clean? (eg. no uncommitted changes) + questiontype: parsons + options: + - "`cd my_project`" + - "`git status`" + - "`git log`" + - "`git diff`" + - "`git commit -am 'commit all changes`" + - "`git push`" + - "`git pull`" + - "`git checkout`" + - "`git add -A`" + correct_options: [0,1] + solution: | + To check if your working directory is clean, you would use the following commands: + 1. `cd my_project` - This changes the current working directory to `my_project`. + 2. `git status` - This shows the status of the working directory and staging area, including any uncommitted changes. + + The other commands are either not relevant or not necessary for this task. + + - title: Git commands + description: | + You've just started a new project and initialized a Git repository. + This is your current terminal prompt: + ```bash + user@computer:~/my_project$ ls + user@computer:~/my_project$ + ``` + How would you create a new file called `README.md`, add it to the staging area, and commit it? + questiontype: parsons + options: + - "`touch README.md`" + - "`git add README.md`" + - "`git commit -m 'Add README file'`" + - "`git push`" + - "`git init`" + - "`git status`" + - "`git log`" + - "`git clone`" + - "`git pull`" + - "`git add and commit README.md`" + - "`git create README.md`" + - "`git commit -am 'Add README file'`" + correct_options: [0,1,2] + solution: | + To create a new file, add it to the staging area, and commit it, you would use the following commands: + 1. `touch README.md` - This creates a new file called `README.md`. + 2. `git add README.md` - This adds the file to the staging area. + 3. `git commit -m 'Add README file'` - This commits the changes with a message. + + Using `git commit -am 'Add README file'` would not work in this case because `README.md` is a + new file that has never been added to the repository before. + The `-a` flag only stages files that are already being tracked by Git. (eg. modified files) + + - title: Git commands + description: | + You have a file called `script.py` in your Git repository. + You made some changes to it and want to see what those changes are before committing. + Which command would you use? + questiontype: parsons + options: + - "`git status`" + - "`git diff script.py`" + - "`git log`" + - "`git commit -m 'Update script.py'`" + - "`git add script.py`" + - "`git push`" + - "`git pull`" + - "`git checkout script.py`" + - "`cd script.py`" + correct_options: [1] + solution: | + To see the changes made to `script.py`, you would use the command: + `git diff script.py` - This shows the differences between the working directory and the staging area for the specified file. + + - title: Git and GitHub + description: | + What is the difference between git and GitHub? + questiontype: freeform + solution: | + Git is a version control system that allows you to track changes in your code and collaborate with others. + GitHub is a web-based platform that uses Git for version control and provides additional features like issue tracking, pull requests, and project management. + In short, Git is the tool, while GitHub is a service that hosts Git repositories. + + - title: Git and GitHub + description: | + Besides the initial commit, should we push our changes directly into the `main` branch? + questiontype: freeform + solution: | + It depends. + + For **smaller projects**, it might be acceptable to push changes directly to the `main` branch. + This can be convenient for quick iterations and personal projects where you are the only developer. + + However, for **larger projects** or when working in a team, it's generally recommended to create a new branch for each feature or bug fix. + This allows for better organization and collaboration, as well as easier code reviews. + By using branches, you can work on multiple features or fixes simultaneously without affecting the main codebase. + Once your changes are complete and tested, you can merge them back into the `main` branch through a pull request. + This helps maintain a clean and organized project history. + + - title: Command line text editors + description: | + You've just installed Git on a new computer and are excited to keep working on your project in Git. + You've made some changes, added them to staging with `git add -A`, then went to commit your changes with + `git commit`. When you press Enter, you see this on screen. + + ``` + + # Please enter the commit message for your changes. Lines starting + # with '#' will be ignored, and an empty message aborts the commit. + # + # On branch main + # Your branch is ahead of 'origin/main' by 1 commit. + # (use "git push" to publish your local commits) + # + # Changes to be committed: + # modified: myfile.txt + # + ~ + ~ + ~ + ~ + ~ + .git/COMMIT_EDITMSG [unix] + "~/myproject/.git/COMMIT_EDITMSG" + ``` + + Pressing keys on your keyboard doesn't seem to do anything. + What is going on? How do you get out of this screen? + + questiontype: multiplechoice + options: + - "You are in a command line text editor called `vim`. To exit, press `Esc`, then type `:wq` and press Enter." + - "You are in a command line text editor called `vim`. To exit, press `Ctrl + Q`." + - "You are in a command line text editor called `vim`. To exit, press `Ctrl + X`, then press Esc." + - "You are in a command line text editor called `nano`. To exit, press `Ctrl + X`, then type `Y` to save changes." + - "You are in a command line text editor called `nano`. To exit, press `Ctrl + Q`." + - "You are in a command line text editor called `nano`. To exit, press `Esc`, then type `:wq` and press Enter." + correct_options: [0] + solution: | + You are in a command line text editor called `vim`. To exit, press `Esc`, then type `:wq` and press Enter. + This will save your changes and exit the editor. If you want to exit without saving, you can type `:q!` instead. + + You can tell that this is `vim` because of the `~` symbols, which indicate empty lines in `vim`, and the "~/myproject/.git/COMMIT_EDITMSG" file path at the bottom. + + - title: Command line text editors + description: | + You've just installed Git on a new computer and are excited to keep working on your project in Git. + You've made some changes, added them to staging with `git add -A`, then went to commit your changes with + `git commit`. When you press Enter, you see this on screen. + + ``` + GNU nano 8.3 COMMIT_EDITMSG + + # Please enter the commit message for your changes. Lines starting + # with '#' will be ignored, and an empty message aborts the commit. + # + # On branch main + # Your branch is ahead of 'origin/main' by 1 commit. + # (use "git push" to publish your local commits) + # + # Changes to be committed: + # modified: myfile.txt + # + [ Read 148 lines (converted from DOS format) ] + ^G Help ^O Write Out ^F Where Is ^K Cut + ^X Exit ^R Read File ^\ Replace ^U Paste + ``` + Pressing keys on your keyboard types onto the screen. + What is going on? How do you get out of this screen? + questiontype: multiplechoice + options: + - "You are in a command line text editor called `vim`. To exit, press `Esc`, then type `:wq` and press Enter." + - "You are in a command line text editor called `vim`. To exit, press `Ctrl + Q`." + - "You are in a command line text editor called `vim`. To exit, press `Ctrl + X`, then press Esc." + - "You are in a command line text editor called `nano`. To exit, press `Ctrl + X`, then type `Y` to save changes." + - "You are in a command line text editor called `nano`. To exit, press `Ctrl + Q`." + - "You are in a command line text editor called `nano`. To exit, press `Esc`, then type `:wq` and press Enter." + correct_options: [3] + solution: | + You are in a command line text editor called `nano`. To exit, press `Ctrl + X`, then type `Y` to save changes. + These keyboard shortcuts are indicated at the bottom of the screen, where `^X` means `Ctrl + X` + + This will save your changes and exit the editor. If you want to exit without saving, you can type `N` instead of `Y`. + + You can tell that this is `nano` because of the application name at the top (GNU nano 8.3) and the keyboard shortcuts listed at the bottom. + + - title: Commit messages + description: | + Suppose you had a recipe for guacamole in a file called `guacamole.txt`. + ``` + Guacamole ingredients: + - avocado + - lemon + - salt + ``` + + You change this file to the following: + ``` + Guacamole ingredients: + - avocado + - lime + - salt + - cilantro + ``` + + What would be a good commit message for this change? + + questiontype: multiplechoice + options: + - "Fixed a typo in guacamole.txt" + - "Updated guacamole recipe to use lime instead of lemon and added cilantro" + - "Added new ingredients to guacamole recipe" + - "Changed guacamole recipe" + - "Guacamole recipe update" + - "Guacamole modified to the traditional recipe" + correct_options: [5] + solution: | + A good commit message should be clear and descriptive, explaining what changes were made and why. + The best option here is: + "Guacamole modified to the traditional recipe" + + This message clearly states what was changed and why, making it easy for others (and yourself) to understand the purpose of the commit in the future. + + - "Fixed a typo in guacamole.txt" is not accurate because there was no typo. + - "Updated guacamole recipe to use lime instead of lemon and added cilantro" duplicates the information in the `git diff` and does not explain why + - "Added new ingredients to guacamole recipe" is vague and doesn't specify what was changed. + - "Changed guacamole recipe" is too vague and doesn't provide enough information. + - "Guacamole recipe update" is also vague and doesn't explain what was changed. + + - title: Git commands + description: | + You're working on two features simultaneously in your Git repository: `feature1` and `feature2`. + `feature1` and `feature2` were branched off of `main` some time ago. + You don't remember if you've fixed a particular bug in `feature1` or `feature2` or `main`. + + How would you check which branch your bugfix commit has been made in? + + questiontype: multiplechoice + options: + - "`git log [branch name]` for each branch" + - "`git log` then `git checkout [branch]` for each branch" + - "`git diff main feature1 feature2`" + - "`git status [branch name]` for each branch" + correct_options: [0] + solution: | + The best way to check which branch your bugfix commit has been made in is to use: + "`git log [branch name]` for each branch" + + This will show you the commit history for each branch, allowing you to see if the bugfix commit is present in that branch. + + The other options are not correct because: + - "`git log` then `git checkout [branch]` for each branch" runs the commands in the wrong order, and using `git checkout` would require checking out each branch, which is unnecessary. + - "`git diff`" shows differences between branches but does not show commit history, and `git diff main feature1 feature2` is not a valid command. + - "`git status [branch name]` for each branch" does not provide information about commit history. + + - title: Git remotes + description: | + You're working on the DSI Shell & Git assignment. + 1. You've cloned the repository from GitHub to your local machine. + 1. You've made some changes to the code + 1. You've staged then committed your changes + 1. Now you want to push your changes to the remote repository on GitHub. + + But you've realized that *instead of cloning your own fork of the repository, you accidentally cloned the original repository.* + + How would you fix this and push your changes to your own fork of the repository? + questiontype: parsons + options: + - "`git remote add origin [your fork URL]`" + - "`git remote rename origin upstream`" + - "`git push origin main`" + - "`git clone [your fork URL]`" + - "`git fetch origin`" + - "`git pull origin main`" + - "`git remote reset origin`" + - "`git reclone [your fork URL]`" + correct_options: [1,0,2] + solution: | + To fix this and push your changes to your own fork of the repository, you would do the following: + 1. `git remote rename origin upstream` - This renames the original repository to `upstream`. + 2. `git remote add origin [your fork URL]` - This adds your fork as the new `origin`. + 3. `git push origin main` - This pushes your changes to your fork on GitHub. + + You may also need to run: + - `git pull origin main` - This fetches the latest changes from your fork and merges them into your local branch. It may not be necessary if there were no changes in your fork since you cloned it. + + The other commands are either not necessary or incorrect for this task. + - `git fetch origin` is not needed because `git pull` already fetches changes. + - `git reclone [your fork URL]` is not a valid command. + - `git remote reset origin` is not a valid command. + - `git clone [your fork URL]` would create a new clone of your fork. Although you could do this, then make all your changes again, it is a very inefficient and error-prone way to solve the problem. diff --git a/03_instructional_team/githubpages/interactive_problems.html b/03_instructional_team/githubpages/interactive_problems.html new file mode 100644 index 0000000..f225972 --- /dev/null +++ b/03_instructional_team/githubpages/interactive_problems.html @@ -0,0 +1,421 @@ + + + + + + + + + + + + + + +
+
+
+

+
+
+
+ + + + \ No newline at end of file