24 Collaborating with GitHub Desktop and VS Code
24.1 Objective
This assignment is divided into three exercises to help you practice using GitHub for version control. You will:
- Add a JSON file with your details.
- Modify an existing Python script.
- Add your information to a shared CSV file.
- Commit and push each set of changes separately to the repository using GitHub Desktop and VS Code.
24.2 Preliminary Setup: Install Required Tools
Before you start, ensure the following tools are installed on your computer:
- GitHub Desktop: Download and install from GitHub Desktop.
- VS Code (Visual Studio Code): Download and install from VS Code.
- Python: Make sure Python is installed. If not, download it from Python.org.
24.3 Step 1: Adding Your JSON File
- Clone the Repository Using GitHub Desktop:
- Open GitHub Desktop.
- Go to File > Clone Repository.
- Select the shared repository (you will find it in the list after being added as a collaborator) or paste its URL in the URL tab.
- Choose a folder on your computer to store the repository and click Clone.
- Open the Repository in VS Code:
- In GitHub Desktop, go to the Repository menu and click Open in Visual Studio Code.
- VS Code will open with the repository folder loaded.
- Create Your JSON File:
In VS Code, navigate to the
data/raw
folder.Right-click the
raw
folder in the file explorer and select New File.Name the file
student_<student_id>.json
, replacing<student_id>
with your unique student ID (e.g.,student_12345.json
).Add the following content to the file:
Save the file by pressing Ctrl+S (Windows) or Cmd+S (Mac).
- Commit and Push Your JSON File:
- Switch back to GitHub Desktop.
- You will see your new JSON file listed as a change.
- In the Summary field, write a clear commit message, e.g.,
Added student JSON file for <student_id>
. - Click Commit to main.
- Push your changes by clicking Push origin in GitHub Desktop.
24.4 Step 2: Modifying the Python Script
- Open the Python File in VS Code:
- In VS Code, navigate to the
hello.py
file in the root directory. - Double-click the file to open it in the editor.
- In VS Code, navigate to the
- Edit the Python File:
Locate the placeholder code in the file. Replace it with the following:
Replace
<Your Name>
with your actual first name (e.g.,print("Alice")
).Save the file by pressing Ctrl+S (Windows) or Cmd+S (Mac).
- Check Your Changes Locally (Optional):
Open a terminal in VS Code by pressing Ctrl+
** (Windows) or **Cmd+
(Mac).Run the script to ensure it works as expected:
- Commit and Push the Python File:
- Switch to GitHub Desktop.
- You will see the modified
hello.py
file listed as a change. - Write a commit message, e.g.,
Modified hello.py to print my name
. - Click Commit to main.
- Push your changes by clicking Push origin.
24.6 Final Steps
- Verify your contributions in the GitHub repository by checking the Commits section on GitHub.
- Confirm that your JSON file, Python script modification, and CSV update are all visible.
24.7 Submission Checklist
- JSON file (
student_<student_id>.json
) added and committed. - Python script (
hello.py
) modified and committed. - CSV file (
students.csv
) updated and committed. - Each step has a separate, descriptive commit message.
- All changes are pushed to the shared GitHub repository.
24.8 Notes
- If you face any issues with VS Code, GitHub Desktop, or GitHub, refer to the official documentation or ask for assistance:
This detailed workflow ensures that students gain experience in both local file management and Git/GitHub operations using professional tools like VS Code.