UCSC Rocket Team 2026/27 Git onboarding Workshop
This exercise provides a simple task that will introduce you to collaborative work through GitHub here at Rocket Team.
Steps to this exercise:
- Assign yourself to the "Missing Data" Issue
- Create your own branch to make your code changes in.
- Follow the instructions on the "Missing Data" issue to make changes accordingly to the files in this repository.
- Commit and push your changes to your branch.
- Once you have made the necessary changes, create a "Pull Request" and fix any merge issues that may appear.
- Request review from @OceancattUCSC.
When using Git, the easiest way to authenticate from the command line is with SSH keys.
SSH keys are a pair of keys: a private key and a public key. You can use them to prove your identity to GitHub and other services. Always keep your private key private and never share it with anyone. You can share your public key with services that need to authenticate you, such as GitHub.
GitHub supports SSH keys for repository access. You can also authenticate with personal access tokens, but SSH keys are the recommended approach for this course.
SSH keys are usually stored in the ~/.ssh directory, where ~ means your home directory. Check for existing keys before generating a new one:
ls -lh ~/.sshKey files usually start with id_. Public keys have a .pub suffix, while private keys have no suffix. If you already have a key you want to use, you can skip to Add your public key to GitHub.
Use ssh-keygen to generate a new key. The default settings are sufficient for this course. Ed25519 is a modern, secure key type:
ssh-keygen -t ed25519 -C "your_email@example.com"When prompted:
- Press Enter to accept the default file location if this is your first key. If you already have a key, enter another memorable filename, such as
~/.ssh/id_github. - Enter a passphrase, or press Enter twice to leave it empty. A passphrase provides additional protection if someone gains access to your computer.
For example:
Enter file in which to save the key (/Users/your-name/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/your-name/.ssh/id_ed25519
Your public key has been saved in /Users/your-name/.ssh/id_ed25519.pub
The command creates two files in ~/.ssh:
id_ed25519: your private key. Never share this file.id_ed25519.pub: your public key. This is the key you can share with GitHub.
Print your public key so you can copy it:
cat ~/.ssh/id_ed25519.pubThe key typically starts with ssh-ed25519 and ends with your email address. Copy the entire line, but do not copy your private key.
Then:
- Open GitHub SSH and GPG keys settings.
- Click New SSH key.
- Give the key a descriptive title, such as
Personal laptop. - Paste the public key into the Key field.
- Click Add SSH key.
You can now use GitHub from the terminal over SSH without entering your GitHub password for every operation.
Here are some quick references for common Git commands and example usage that are useful when working with a Git repository.
-
git init
Initialize a new Git repository in the current folder.git init
-
git clone <repository-url>
Copy an existing repository from a remote server to your machine.git clone https://github.com/example/project.git
-
git status
Shows the current state of the repository, including modified and staged files.git status
-
git log
View the commit history.git log --oneline --decorate --graph --all
-
git diff
Show changes between your working tree and the last commit.git diff
-
git diff --staged
Show changes that are currently staged.git diff --staged
-
git add <file>
Stage a specific file for commit.git add README.md
-
git add .
Stage all modified files in the current repository.git add . -
git commit -m "message"
Save the staged changes with a commit message.git commit -m "Add project README" -
git restore <file>
Revert a file to its last committed state.git restore README.md
-
git restore --staged <file>
Unstage a file without losing its changes.git restore --staged README.md
-
git branch
List all branches in the repository.git branch
-
git checkout -b <branch-name>
Create and switch to a new branch.git checkout -b feature/new-page
-
git switch <branch-name>
Switch to an existing branch.git switch main
-
git merge <branch-name>
Merge another branch into the current branch.git merge feature/new-page
-
git remote -v
Show the configured remote repositories.git remote -v
-
git pull origin <branch-name>
Fetch and merge changes from a remote branch.git pull origin main
-
git push origin <branch-name>
Upload local commits to a remote branch.git push origin feature/new-page
-
git remote add origin <repository-url>
Link a local repository to a remote repository.git remote add origin https://github.com/example/project.git
-
git fetch
Download remote updates without merging them.git fetch origin
-
git stash
Temporarily save uncommitted changes.git stash
-
git stash pop
Reapply the most recent stashed changes.git stash pop
-
git status -sb
Short status format that is easier to scan.git status -sb
git clone https://github.com/example/project.git
cd project
git checkout -b feature/update-readme
git add README.md
git commit -m "Update README content"
git push origin feature/update-readme- Commit often with clear, descriptive messages.
- Pull the latest changes before pushing your work.
- Use branches to keep separate work isolated.