theme | favicon | layout | coverBackground | sectionBackground | themeConfig | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
./ |
./assets/favicon.ico |
cover |
./assets/cover.png |
./assets/section.png |
|
Fearless coding and reproducible research
layout: image-right image: "./assets/scratch_comic_small.png" backgroundSize: contain imageSize: 100% transition: fade-out
Challenges Faced Without Version Control
- "Where is this script we used in the last project?"
- "Which version of the script is the right one?"
- "I accidentally overwrote a file."
- "Where's the latest data?"
- "Who changed what, and why?"
Reproducibility, teamwork, and fearless coding
- 🔁 Track Changes: See what changed and when.
- 🧑🤝🧑 Collaborate: Work with others seamlessly.
- 💾 Backup: Save your work automatically (with GitHub)
- 🔬 Reproducibility: Ensure your research can be repeated.
- 📢 Share: Publish your work with the world.
::left::
A Distributed Version Control System
Git is a free and open-source tool designed to help developers:
- Track changes in their files over time.
- Collaborate with others on the same project.
- Experiment with new ideas without fear of losing progress.
::right::
gitGraph TB:
commit id: "version 0.0"
commit id: "version 0.1"
checkout main
branch Steven
commit id: "new feature"
commit id: "documentation"
branch Jane
checkout Steven
commit id: "fix code"
checkout main
merge Steven
commit id: "version 0.2"
checkout Jane
commit id: "fix documentation"
checkout main
merge Jane id: "version 0.4.2"
A Distributed Version Control System
Key Features of Git
- Version History: Keep a detailed history of every change made to your files.
- Branching: Create separate branches to work on new features or fixes.
- Merging: Combine changes from different branches seamlessly.
- Distributed: Work offline—Git stores the entire repository locally.
- Speed: Perform operations like commits and branching quickly.
A Platform for Collaboration and Hosting
GitHub is a web-based platform built on top of Git. It provides tools for:
- Hosting repositories: Store your code and project files in the cloud.
- Collaboration: Work with others through pull requests, issues, and discussions.
- Version control: Track changes and manage your project history.
- Automation: Use GitHub Actions for CI/CD workflows.
- Publishing: Host websites and documentation with GitHub Pages.
Version control tool vs platform for collaboration
Practical ways GitHub powers open ecological research
flowchart TD
style WD fill:#E3F2FD,stroke:#2196F3,stroke-width:2px
style STG fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px
style LOCAL fill:#C8E6C9,stroke:#388E3C,stroke-width:2px
style REMOTE fill:#FFCDD2,stroke:#D32F2F,stroke-width:2px
WD["📂 Working Directory"]
STG["🗃️ Staging Area"]
LOCAL["📦 Local Repository"]
REMOTE["🌐 Remote Repository"]
WD -->|git add| STG
STG -->|git commit| LOCAL
LOCAL -->|git push| REMOTE
REMOTE -->|git fetch / git pull| LOCAL
LOCAL -->|git checkout| WD
Set up your Git environment
# Step 1: Set your user info (only once)
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
# Step 2: Initialize a new repository
git init my_first_project
cd my_first_project
Track and save your work
# Step 3: Create a file
echo "Hello Git" > README.md
# Step 4: Track the file
git add README.md
# Step 5: Save a snapshot
git commit -m "Initial commit"
Always write meaningful commit messages to describe what you’ve changed and why.
Parallel development made easy.
# Create and switch to a new branch
git checkout -b feature-idea
# Work on your changes, then:
git add .
git commit -m "Add awesome feature"
# Merge your branch into main
git checkout main
git merge feature-idea
Use git branch -d [branch]
to delete branches you no longer need and keep your repo clean.
Save changes without committing.
git stash # Temporarily saves uncommitted changes
git stash list # See all stashed changes
git stash apply # Apply the most recent stash
git stash pop # Apply & remove the stash
git stash drop # Delete a stash
Git Stash helps you pause work, switch tasks, and keep your workspace clean without committing changes.
Rewrite your commit history
# Rebase your branch onto main
git checkout feature-branch
git rebase main
# Resolve conflicts if needed, then:
git add <file>
git rebase --continue
Don’t panic — how to fix Git mistakes.
git restore --staged <file> # Undo git add
git reset --soft HEAD~1 # Undo last commit (keep changes)
git reset --hard HEAD~1 # Undo last commit (discard changes)
git checkout HEAD -- <file> # Restore deleted file
Use git diff
before resetting to see what changes you’re about to discard
View the commit history of a repository
git log --oneline --graph ## add `--oneline` or `--graph` for visual clarity
git blame my_script.py. ## see who edited each line of a file
Connect your local repo to the cloud
- If you don’t already have a GitHub account, sign up here.
- Once signed in, create your repository.
git remote add origin https://github.com/yourusername/your-repo.git # Add the remote (replace with your repo URL)
git branch -M main # Set the default branch
git push -u origin main # Push your commits
::left::
Collaborate with kindness and clarity
- Write clear commit messages (what + why)
- Don’t commit broken code to main
- Use .gitignore to keep clutter out
- Clean up unused branches regularly
- Be kind and constructive in Pull Request comments
- Always write a description when opening a PR
::right::
Prefer clicking to typing? No worries!
- GitHub Desktop – beginner-friendly official GUI
- GitKraken – sleek UI, lots of power
- VS Code – Git integration built-in
- RStudio – Seamless Git integration for R projects
- Sourcetree – Visual Git client by Atlassian
- Tower – Intuitive Git client for macOS and Windows
- JupyterLab Git – Git extension for JupyterLab
“The best way to learn Git is to use it regularly"
✅ Don’t be afraid to break things
✅ Ask questions, open issues
✅ Collaborate early and often