Version Control
Step-by-step guidance for each exercise. The original exercise prompt is shown as the title — click to expand for detailed instructions.
Local version control
git repository within the analysis folder
- Open the
analysisfolder in VSCode (File→Open Folder) - Click the
Source Controlicon in the left sidebar (or pressCtrl+Shift+G) - Click
Initialise Repository
Your files will now appear in the Source Control panel with U (untracked) badges.
If you haven’t already, open the analysis folder as a project (File → New Project → Existing Directory). With this project open:
- Go to
Tools→Project Options→Git/SVN - Change the version control system to
Gitand click OK - Restart RStudio when prompted — the
Git tabwill appear in the top-right panel
cd path/to/analysis
git init
git statusgit status will show all your files as untracked (in red). This is expected.
.gitignore — which files should you exclude?
Create a file called .gitignore in the root of your analysis folder. Files and folders listed here will not be tracked by Git.
At minimum, exclude:
# Data files
data/raw/
data/processed/
# Results
results/
# System files
.DS_Store
.Rhistory
__pycache__/
*.pyc
# IDE files
.vscode/
.Rproj.user/.gitignore files — search for “Python” or “R” to get a solid starting template.
environment.yml or renv.lock be tracked? Yes — these should be committed, as they are part of making your code reproducible.
Stage only the files you want to track.
- In the Source Control panel, hover over each file and click
+to stage it - Stage your script(s),
environment.yml,.gitignore, and any other relevant files - Type a commit message in the box at the top, e.g.
Initial commit: analysis scripts and environment - Click
Commit(✓)
- In the
Git tab, tick the checkbox next to the files you want to stage — badge changes from?toA - Click
Commit - Write a commit message in the box, e.g.
Initial commit: analysis scripts and environment - Click
Commit
git add analysis.py environment.yml .gitignore # list your files
git commit -m "Initial commit: analysis scripts and environment"README.md that describes the project, then commit your changes
Create a README.md file in the root of your analysis folder. It should cover:
- What this code does (one paragraph is fine)
- Dependencies — refer to the
environment.ymlorrenv.lock - How to run it — what order to run scripts, any inputs needed
- Outputs — what does running the code produce?
A minimal example:
# Spacewalk Analysis
Analysis of NASA EVA (spacewalk) data, exploring duration trends and crew patterns.
## Dependencies
See `environment.yml` (Python) or `renv.lock` (R) for full environment details.
## How to run
1. Set up the environment from `environment.yml` / `renv.lock`
2. Run `spacewalk_analysis.py` / `spacewalk_analysis.R`
## Outputs
Figures are saved to `results/`.Once written, stage and commit your README.md: Added README with project description and run instructions
Remote version control
spacewalk_analysis repository to GitHub
- Open the
Source Controltab (Ctrl+Shift+G) - Click
Publish Branch(appears after your first commit) - Sign in to GitHub if prompted
- Choose
PublicorPrivate - VSCode creates the repository on GitHub and pushes your commits automatically
In the console:
usethis::use_github()Follow the prompts to choose visibility and confirm. RStudio will open your new repository in a browser.
- Open GitHub Desktop and sign in to your GitHub account
- Click
File→Add Local Repository - Browse to your
analysisfolder and clickAdd Repository - Click
Publish repositoryin the top bar - Choose
PublicorPrivate, then clickPublish Repository
usethis::create_github_token() to generate one.
Open your repository on GitHub and explore:
- Code tab — your file structure, with
README.mdrendered below - Commits — click the clock icon (or “X commits”) to see your full commit history
- Each commit — click any commit to see exactly what changed (green = added, red = removed)
Check that:
- Your
README.mdrenders correctly - Your
.gitignoreis present (and working — data/results folders should not appear) - Your environment file (
environment.ymlorrenv.lock) is there
Make a small change to your README.md or analysis script (e.g. add a comment or update a description), then push it.
- Save your changes
- Go to the
Source Controltab — the changed file will appear with anM(modified) badge - Stage the file (
+), write a commit message, and clickCommit - Click
Sync Changes(↑↓) to push to GitHub
- Save your changes
- In the
Git tab, tick the checkbox next to the modified file - Click
Commit, write a message, and clickCommit - Click the
Pushbutton (↑)
Refresh your GitHub page to confirm the change appears in the commit history.
Creating & cloning
your-username
- Go to github.com and sign in
- Click the
+in the top-right →New repository - Set the repository name to exactly your GitHub username (e.g. if your username is
comfyclouds, the repo is namedcomfyclouds) - Set visibility to
Public - Tick
Add a README file - Click
Create repository
- Go to your new repository on GitHub
- Click the green
Codebutton → click theOpen with GitHub Desktopbutton (or copy the URL for manual cloning) - If using GitHub Desktop, follow the prompts to choose a local folder and clone the repository
- Open the cloned folder in your IDE (VSCode or RStudio)
README.md, and push to GitHub
Browse awesome-readme for inspiration — look for profiles (not project READMEs) that match your style.
Edit the README.md in your cloned username repository. Ideas to include:
- A short bio (who you are, what you work on)
- Your research interests or current projects
- Links to your lab website, ORCID, or publications
- Tools or languages you use
Commit as you go — don’t wait until the end.
Push your finished README to GitHub
Visit your GitHub profile page (github.com/your-username) to see it live.