Welcome to the Git 101 Workshop! This project is designed to teach Code Network members the fundamentals of using Git and GitHub for collaborative software development.
- Workshop Goal
- Project Description
- Prerequisites
- Choosing Your Git Tool
- Workshop Steps
- Alternative Workflows
- Useful Commands Reference
- Troubleshooting
- Contributing Guidelines
- Questions?
- Additional Resources
By the end of this workshop, you will learn how to:
- Fork a repository on GitHub
- Clone a repository to your local machine
- Make changes to code
- Stage and commit your changes
- Push changes to your remote repository
- Create a pull request to contribute to the original project
This is a simple C# console application that displays a welcome message and lists all the awesome coders who attended this workshop. Your task is to add your name to the attendees list!
Before starting, make sure you have:
- Git installed on your computer (required for all options)
- Note: Git CLI must be installed first, regardless of which Git tool you choose. GitHub Desktop is just a GUI wrapper around Git and requires Git to be already installed.
- A GitHub account
- (Optional).NET 8.0 SDK installed (to run the program)
- A code editor (e.g., NotePad++, Visual Studio, VS Code, or Rider)
You have three main options for working with Git and GitHub. Choose the one that best fits your comfort level:
Quick Decision Guide:
- New to Git? → Start with GitHub Desktop (easiest to visualize)
- Want to learn Git deeply? → Use Git CLI (useful for advanced features)
- Want GitHub-specific features? → Try GitHub CLI (powerful shortcuts)
- Can't decide? → Git CLI is the most versatile and widely used
The traditional Git command-line tool. Best for understanding Git fundamentals.
Setup:
- Download and install from git-scm.com/install
- Open terminal/command prompt and verify installation:
git --version
- Configure your identity:
git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
- Set up authentication for Git CLI: If you're using HTTPS URLs to clone/push, you'll need a Personal Access Token (PAT). Click here to create one
Best for: Learning Git fundamentals, available everywhere, most documentation uses this. Also supports complex operations that GUI tools sometimes don't support
GitHub's official CLI tool with enhanced GitHub integration.
Setup:
- Download from cli.github.com
- Install and verify:
gh --version
- Authenticate with GitHub:
Follow the prompts to connect to your GitHub account
gh auth login
Best for: Streamlined GitHub workflows, creating PRs from terminal, managing issues
A graphical application for Git and GitHub operations.
Setup:
- Download from desktop.github.com
- Install and open the application
- Sign in with your GitHub account
- Configure your Git settings in Options/Preferences
Best for: Visual learners, beginners who prefer GUIs, easy conflict resolution
- Navigate to the original repository on GitHub
- Click the "Fork" button in the top-right corner
- This creates a copy of the repository under your GitHub account
Note: If you're using GitHub CLI or GitHub Desktop, skip to the Alternative Workflows section below for tool-specific instructions.
Using Git CLI:
- On your forked repository page, click the green "Code" button
- Copy the URL (HTTPS or SSH)
- Open your terminal/command prompt
- Navigate to where you want to store the project
- Run the clone command:
git clone <your-fork-url>
cd git-101-2026- Open
Program.csin your code editor - Find the
attendeesarray (around line 1-6) - Add your name to the list, following the existing format:
string[] attendees =
[
"William Qu",
"Angus Wong",
...
"Your Name Here", // Add your name here, and leave a trailing comma!
// Add your name above this line! (Do not delete this)
];- Save the file
Run the program to see your name in the list:
dotnet runNote: GitHub CLI and GitHub Desktop users, see Alternative Workflows for your specific steps.
Using Git CLI:
Stage the file you modified:
git add Program.csOr stage all changes:
git add .Check what's staged:
git statusCreate a commit with a descriptive message:
git commit -m "Add [Your Name] to attendees list"Push your changes to your forked repository on GitHub:
git pushFirst time using Git CLI? You'll be prompted for authentication:
- Enter your GitHub username
- Enter your Personal Access Token (the one you created earlier)
- Press Enter to continue
Note: If you get an error saying "remote: Invalid username or token. Password authentication is not supported for Git operations.", don't worry! Your token may have expired. Just run git push again - you'll be asked for your credentials again. Create a new PAT and paste it in.
Note: GitHub CLI users can create PRs directly from the terminal - see Alternative Workflows.
Using Git CLI or GitHub Desktop:
- Go to your forked repository on GitHub
- You should see a prompt saying "Compare & pull request" - click it
- If not, click "Pull requests" tab, then "New pull request"
- Add a title and description for your pull request
- Click "Create pull request"
- Wait for the maintainer to review and merge your contribution!
If you chose GitHub CLI, here are the equivalent commands:
Fork the repository:
gh repo fork <original-repo-url> --clone
cd git-101-2026Stage, commit, and push:
git add Program.cs
git commit -m "Add [Your Name] to attendees list"
git pushCreate a pull request:
gh pr create --title "Add [Your Name] to attendees list" --body "Adding my name to the workshop attendees list"View your pull request:
gh pr view --webIf you chose GitHub Desktop, follow these steps:
Fork and clone:
- Go to the original repository on GitHub website
- Click "Fork" button
- Open GitHub Desktop
- Go to File → Clone Repository
- Select your forked repository and choose a local path
- Click "Clone"
Make changes and commit:
- Make your changes to
Program.csin your code editor - GitHub Desktop will automatically detect changes
- Review changes in the "Changes" tab
- Enter a commit message in the summary field: "Add [Your Name] to attendees list"
- Click "Commit to main"
Push and create PR:
- Click "Push origin" button to push to your fork
- Click "Create Pull Request" button
- GitHub will open in your browser
- Fill in the PR details and click "Create pull request"
Here are some commands you'll find helpful:
# Basic workflow
git add <filename> # Stage a file for commit (replace <filename> with the file you want to commit)
git add . # Stage all changes
git commit -m "message" # Create a commit with message
git push # Push to remote repository
git pull <remote> <branch> # Pull latest changes from remote (<remote> = remote alias like "origin", <branch> = branch name)
# View and manage
git status # Check the status of your working directory
git log # View commit history
git diff # See what changes you've made
git branch # List branches
git checkout -b <branch> # Create and switch to a new branch
git checkout <branch> # Switch to an existing branch
git checkout <commit> # Switch to a specific commit (replace <commit> with commit hash)
git remote -v # View your remotes (origin, upstream)
# Update your fork
git fetch <remote> # Get latest changes from remote repo (e.g., upstream)
git merge <remote>/<branch> # Merge changes into your current branch (e.g., upstream/main)
# Undo mistakes (use carefully!)
git reset --soft HEAD~1 # Undo last 1 commit (keeps staged changes)
git stash # Temporarily save uncommitted changes (removes them from working directory, stores on stack)
git stash pop # Restore stashed changes back to working directory and remove from stackIf you're using GitHub CLI, here are some commands:
# Fork and clone
gh repo fork <repo> --clone # Fork a repo and clone it locally (replace <repo> with repo URL)
# Pull requests
gh pr create # Create a pull request
gh pr list # List your pull requests
gh pr status # Check status of your PRs
gh pr view --web # View a PR in the browser
# Issues
gh issue list # View issues
gh issue create # Create a new issue
# Repository management
gh repo view # View repository details
gh repo sync # Sync your fork with upstreamIn GitHub Desktop, you can manage your workflow visually:
- View changes: Changes tab shows modified files and their status
- View history: History tab displays all your commits with details
- Create branch: Branch menu → New Branch (or use the branch dropdown)
- Switch branches: Click current branch dropdown to select a branch
- Pull changes: File menu → Pull, or click "Fetch origin" then "Pull origin" button (pulls from your fork to local)
- Push changes: File menu → Push, or click "Push origin" button (pushes from local to your fork only)
- View conflicts: Conflicted files appear in Changes tab with "Open in editor" option
If someone else added their name in the same location, you might encounter a merge conflict. Don't worry!
Using Git CLI:
- Open the conflicted file in your editor
- Look for conflict markers (
<<<<<<<,=======,>>>>>>>) - Edit the file to keep both changes
- Remove the conflict markers
- Stage and commit the resolved file:
git add Program.cs git commit -m "Resolve merge conflict"
Using GitHub CLI: Same as Git CLI - GitHub CLI uses standard Git for conflict resolution
Using GitHub Desktop:
- GitHub Desktop will show conflicted files in the Changes tab
- Click "Open in [your editor]" on the conflicted file
- Edit to resolve conflicts and remove markers
- Save the file
- Return to GitHub Desktop - it will detect the resolution
- Click "Commit merge" to complete the resolution
Resolve on GitHub Website You can also resolve conflicts directly in your browser:
- Go to the Pull Request page on GitHub
- Scroll down to see the conflict markers in the file diff
- Use GitHub's inline editor to resolve each conflict
- Click "Keep both version" if you want to merge both changes
- Or choose one version (yours or theirs) as needed
- After resolving all conflicts, click "Mark conversation as resolved"
- Commit the changes from the Pull Request page
If the original repository has new changes:
Using Git CLI:
# Add the original repository as a remote (one-time setup)
git remote add upstream <original-repo-url>
# Fetch and merge updates
git fetch upstream
git merge upstream/mainUsing GitHub CLI:
# Sync your fork with the original repository
gh repo syncUsing GitHub Desktop:
- Go to Branch menu → Merge into current branch
- Select "upstream/main" (you may need to add the upstream remote first)
- Or use Repository → Repository Settings → Remote to add upstream
- Then fetch and merge from Branch menu
Using GitHub Website:
- Go to your fork on GitHub
- Click the green "Sync fork" button (if available)
- After syncing, click "Update Branch" button that appears
- Use your real name or preferred name
- Be respectful and supportive of other learners
- Join our Code Network Discord for support and discussions
If you get stuck or have questions during the workshop, don't hesitate to ask the workshop facilitators or your fellow attendees. We're all here to learn!
Happy coding and welcome to the world of version control!
