Using GitHub for Student Projects

This tutorial walks through setting up GitHub for a student project where the student works individually and shares progress with the professor for monitoring and review. It covers setup on both macOS and Windows, including installing Git, creating an SSH key, and using both the terminal and a GitHub GUI client. It also shows how to integrate GitHub with Visual Studio Code (VS Code).


1. Installing Git

1.1. On macOS

  1. Install Git: Git is typically pre-installed on macOS. Verify by typing:
    git --version If it’s not installed, install it using Homebrew:
    brew install git
  2. Configure Git:
    git config --global user.name "Your Name"
    git config --global user.email "your_email@example.com"

1.2. On Windows

  1. Download and Install Git:
    • Download Git for Windows from https://git-scm.com/.
    • During installation:
      • Choose “Use Git from the Command Prompt.”
      • Select “OpenSSL Library” for HTTPS.
      • Enable “Checkout Windows-style, commit Unix-style line endings.”
  2. Verify Installation: Open Git Bash and type:
    git --version
  3. Configure Git:
    git config --global user.name "Your Name"
    git config --global user.email "your_email@example.com"

2. Set Up GitHub

2.1. Create an SSH Key

  1. Generate an SSH Key:
    • On macOS or Windows (Git Bash), run:b
      ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
      Press Enter to save it in the default location (~/.ssh/id_rsa).
      Leave the passphrase empty or set one if desired.
  2. Add the SSH Key to GitHub:
    • Copy the SSH key to your clipboard:
      cat ~/.ssh/id_rsa.pub
    • Log in to GitHub, go to Settings > SSH and GPG keys, and click New SSH key.
    • Paste the key and save it.
  3. Test the SSH Connection:
    ssh -T git@github.com You should see a success message.

2.2. Create a GitHub Repository

  1. Create a New Repository:
    • Log in to GitHub.
    • Click New or visit https://github.com/new.
    • Name the repository (e.g., student-project), add a description, and select Private.
    • Do not initialize with a README or .gitignore.
  2. Share the Repository:
    • Go to Settings > Collaborators and Teams.
    • Add your professor’s GitHub username jimskon as a collaborator. He will receive an invitation to accept.

3. Clone the Repository Locally

  1. Copy the Repository URL:
    • Go to the repository page on GitHub.
    • Click Code > SSH and copy the URL.
  2. Clone the Repository: Open a terminal or Git Bash and run:
    git clone git@github.com:username/student-project.git
  3. Navigate to the Project Directory:
    cd student-project

4. Basic Git Commands

4.1. Add and Commit Changes

  1. Create or Edit Files: Add files or make changes in the repository folder.
  2. Stage Changes:
    git add .
  3. Commit Changes:
    git commit -m "Initial commit with project setup"

4.2. Push Changes to GitHub

Upload changes to the remote repository:

git push origin main

4.3. Pull Changes from GitHub

To ensure you have the latest changes:

git pull origin main

5. Working with Branches

  1. Create a Branch:
    git checkout -b feature-branch
  2. Switch Between Branches:
    git checkout main
  3. Push a Branch:
    git push origin feature-branch
  4. Merge a Branch: After testing the branch, merge it into main:
    git checkout main git merge feature-branch
  5. Delete a Branch:
    git branch -d feature-branch

6. Using GitHub Desktop (Optional GUI Client)

  1. Download GitHub Desktop:
  2. Clone a Repository:
    • Open GitHub Desktop and click File > Clone Repository.
    • Paste the SSH URL from GitHub and clone.
  3. Commit and Push Changes:
    • Make changes to your files locally.
    • In GitHub Desktop, click Commit to main, then click Push origin.

7. Integrate GitHub with VS Code

  1. Install Git Integration in VS Code:
    • Open VS Code.
    • Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X on macOS).
    • Install the GitHub Pull Requests and Issues extension.
  2. Open the Cloned Repository in VS Code:
    code student-project
  3. Commit and Push from VS Code:
    • Use the Source Control panel in VS Code.
    • Stage changes, write a commit message, and push.
  4. Use GitHub Copilot:
    • Install the GitHub Copilot extension.
    • Authenticate Copilot and start coding with AI-powered suggestions.

Add James Skon’s public key to Github

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCznmJwSnYjH1lRz7ezF8qG5NK4IgyYTZ3AoXl2pnITxBciacLshTphU2/79DrkyPQxM750ZfXN6Jjr53ozw7ahEzIi/ndcLkRompq+pDzHtYKkeLsldOMPAY45WxS4WGiDdojqzwn0b9hvcMKTJjo3KArxXakoBY7MqARIkKQ+Syzjn+rLnf3szMBh2gJEb8FcRaKCy+ezCgKmuqlyTunV/oxZs91h6taNXE9CSdJAIZs+dLKy8NFUFlKKmfV6s59s8TOXvVC8zfJIkTg+sC2EEb5FVffG4djL0X1eyrMoGtKrUNDWvP1OjK+JzfYnMalPA3tvjKDJRGUNb9Kwd44EiCaEBb67BxiXWxjtDXWHLl2cHd4ApFgIkU84cAc7sgx4GIKeIisbMoFfECnD1TOhpnBt9XE9S4dnsBlTxyb/R2v8NtEZy9Q5s+WzQIdYuiNu5+OTPEiitllmEDHhfvIv212vS43kX8/3J8JafmvdK8D55RDY7XZn7X8+szq2AQts/nMiUdwDxzEL6pps3IKC/BJeL5wz4mnTII73ZrBi9OZjIfSPpigPcKm8PELD36KGaHK+JmUxwOBb5LZKLUFRpA6yOCVXpj1IxgY6FKp+TaAkLBUP+lm5dEIGKTehcKiFw/smM7KtCfw3Y9Dms59GIb2dwPhrKImLZfRfm7HDVw== skonjp@k120716
Scroll to Top