Workshop for students taking CS50P at Aryaloka (CS50x Python at Aryaloka): basic Git usage on CLI and in VSCode and GitHub as preparation for the final project.
First step: click the "Fork" button in the top right corner of the repo, to create your own version of this repo. Then you can use the below check-list to complete the tasks.
Then in your own fork:
- Check off the tasks below as you complete them by putting an
xin the square brackets like- [x].
Important
Any link below, right click and "open in new tab" to keep this editor open.
-
Watch one of these lectures (up until specified time, you can watch more later):
- CS50 Seminars 2023 - How To Use Git and GitHub up to 20:24.
- CS50 An Introduction to Git and GitHub by Brian Yu up to 15:35.
-
Create a new codespaces with VSCode for your repo
- Click on the green "<> Code" dropdown button > select "Codespaces" tab > click the "Create codespace on main" button.
-
Practice Git commands: VSCode Source Control GUI
-
Change one file
- In your VSCode, switch to the Source Control view in the left sidebar (Ctrl+Shift+G)
- In your VSCode, edit the
README.mdfile e.g. add a new line or check off a completed task.- Observe that the
README.mdfile is marked as "changed" in the Source Control view.
- Observe that the
- Click the "+" button next to the file to add this file to the staging area.
- Write a Message in the input field at the top e.g. "Updated README with completed tasks". Then press the "✔ Commit" button.
- Observe that your new commit is now visible in the commit tree in the lower part of the Source Control sidebar.
- Press the "Sync Changes" button to push (upload) the changes to Github.com
- Go to your repository on Github.com
https://github.com/<your-github-username>/workshop-git-and-github- Observe that your changes to your files are visible on GitHub.
- Now press the "Commits" link below the green "<> Code"
- Observe that your new commit is listed.
- Click on the commit in the list to see the commit diff, the incremental changes did commit did.
-
Change several files
- Create a few new files with the
codecommand e.g.$ code file1.md file2.md. Write something in each and save both withctrl+safter (needed as it's a new file). - Repeat the steps from the previous task to create new commits, and observe how the staging area is changing, and new commits appear in the commit tree timeline.
- Create a few new files with the
-
-
Practice Git commands: command-line (CLI) commands
-
First CLI commit
- In your VSCode, edit the
README.mdfile e.g. add a new line or check off a completed task. - Create a two new file like
$ code prog1.py prog2.pyand write something in them. Save both withctrl+safter (needed as it's a new file). - Observe changes files with
$ git statusand with$ git diff. - Decide that you want to commit only the changes to the
README.mdfile and theprog1.pyfile. Do so by adding it to the staging area with$git add README.md prog1.py. - Commit the staged changes with
$ git commit -m "Update README and add prog1". - Observe the updated commit history with
$ git logor with included diff$ git log -p. Press theqto quit the log view. - Push (upload) the new commits to the remote (GitHub) with
$git push origin. - Go to your repository on Github.com
https://github.com/<your-github-username>/workshop-git-and-github- Observe that your changes to your files are visible on GitHub.
- Now press the "Commits" link below the green "<> Code"
- Observe that your new commit is listed.
- Click on the commit in the list to see the commit diff, the incremental changes did commit did.
- In your VSCode, edit the
-
Second CLI commit
- Remember that you did not commit the new file
prog2.pyyet. Repeat the commands above to create a new commit that add this new file.
- Remember that you did not commit the new file
-
