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
- Install Git: Git is typically pre-installed on macOS. Verify by typing:
git --versionIf it’s not installed, install it using Homebrew:brew install git - Configure Git:
git config --global user.name "Your Name"git config --global user.email "your_email@example.com"
1.2. On Windows
- 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.”
- Verify Installation: Open Git Bash and type:
git --version - 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
- 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.
- On macOS or Windows (Git Bash), run:b
- 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.
- Copy the SSH key to your clipboard:
- Test the SSH Connection:
ssh -T git@github.comYou should see a success message.
2.2. Create a GitHub Repository
- 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.
- Share the Repository:
- Go to Settings > Collaborators and Teams.
- Add your professor’s GitHub username
jimskonas a collaborator. He will receive an invitation to accept.
3. Clone the Repository Locally
- Copy the Repository URL:
- Go to the repository page on GitHub.
- Click Code > SSH and copy the URL.
- Clone the Repository: Open a terminal or Git Bash and run:
git clone git@github.com:username/student-project.git - Navigate to the Project Directory:
cd student-project
4. Basic Git Commands
4.1. Add and Commit Changes
- Create or Edit Files: Add files or make changes in the repository folder.
- Stage Changes:
git add . - 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
- Create a Branch:
git checkout -b feature-branch - Switch Between Branches:
git checkout main - Push a Branch:
git push origin feature-branch - Merge a Branch: After testing the branch, merge it into
main:git checkout main git merge feature-branch - Delete a Branch:
git branch -d feature-branch
6. Using GitHub Desktop (Optional GUI Client)
- Download GitHub Desktop:
- Visit https://desktop.github.com/ and install.
- Clone a Repository:
- Open GitHub Desktop and click File > Clone Repository.
- Paste the SSH URL from GitHub and clone.
- 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
- Install Git Integration in VS Code:
- Open VS Code.
- Go to the Extensions view (
Ctrl+Shift+XorCmd+Shift+Xon macOS). - Install the GitHub Pull Requests and Issues extension.
- Open the Cloned Repository in VS Code:
code student-project - Commit and Push from VS Code:
- Use the Source Control panel in VS Code.
- Stage changes, write a commit message, and push.
- 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
