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 x
in the square brackets like - [x]
:
-
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.
-
Watch one of these lectures:
-
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.md
file e.g. add a new line or check off a completed task.- Observe that the
README.md
file 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
$ code <filename>
command. - 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.md
file e.g. add a new line or check off a completed task. - Create a two new file like
$ code prog1.py prog2.py
and write something in them - Observe changes files with
$ git status
and with$ git diff
. - Decide that you want to commit only the changes to the
README.md
file and theprog1.py
file. 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 log
or with included diff$ git log -p
. Press theq
to 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.py
yet. Repeat the commands above to create a new commit that add this new file.
- Remember that you did not commit the new file
-