This guide explains how to use Claude Code to develop R code that syncs with GitHub, and how to get that code running on your local machine.
There are three locations your code lives:
GitHub (cloud) ←→ Your Local Computer → R Session
↑ ↑ ↑
Claude Code git pull/push source()
pushes here syncs these loads codeClaude Code works directly with GitHub. Your local computer syncs with GitHub using Git. R runs code from your local files.
Claude Code has two input areas:
| Location | Purpose | When to Use |
|---|---|---|
| Top left box | Start a new session | Beginning a new task |
| Bottom right box | Continue current session | Follow-up questions, refinements |
The left sidebar shows your session history. Click any session to view and continue it.
In the top left box, describe what you want:
Claude Code will read your repository files, make changes, and push them to GitHub.
Claude Code doesn't have an upload button. To share reference materials:
Option 1: Add files to your repository
docs/ folder)Option 2: Create a summary document
docs/dsp_method.md)Option 3: Paste key excerpts
Claude Code doesn't modify your main code directly. Instead, it:
claude/fix-dsp-permutation-qap-...)This keeps your main code safe until you review and approve changes.
After Claude Code works, you'll see yellow banners like:
claude/fix-dsp-permutation-qap-... had recent pushes
[Compare & pull request]Using the command line:
cd /path/to/your/QAPtest # Navigate to your repo folder
git pull # Download and merge changesUsing RStudio:
Using R directly:
setwd("/path/to/your/QAPtest")
system("git pull")source("qap_symmetric_homophily_test.R")If you want to test changes before merging on GitHub:
# Download branch information from GitHub
system("git fetch origin")
# Merge the specific branch into your current branch
system("git merge origin/claude/fix-dsp-permutation-qap-...")
# After testing, push the merged result back to GitHub
system("git push")Use this when you want to test changes locally before they appear on the main branch on GitHub.
If you don't have the repository on your computer yet:
git clone https://github.com/StephenBorgatti/QAPtest.git
cd QAPtestOr in R:
system("git clone https://github.com/StephenBorgatti/QAPtest.git")
setwd("QAPtest")git pullsource("your_file.R")system("git branch") # Shows local branches, * marks current
system("git status") # Shows current branch and any uncommitted changesIf you made local changes you want to throw away:
system("git checkout -- .") # Discard all uncommitted changes
system("git pull") # Get latest from GitHubYou have uncommitted local changes. Options:
# Option A: Discard your local changes
system("git checkout -- .")
system("git pull")
# Option B: Stash your changes temporarily
system("git stash")
system("git pull")
system("git stash pop") # Restore your changesSame as above — you have local modifications that conflict with incoming changes.
system("git status") # Will tell you if you're ahead or behind
system("git pull") # If behind, this catches you up
system("git push") # If ahead, this pushes your commits| Task | Command |
|---|---|
| Get latest code from GitHub | git pull |
| See what branch you're on | git branch |
| See status of local changes | git status |
| Download branch info without merging | git fetch origin |
| Discard local changes | git checkout -- . |
| Clone a repository | git clone <url> |
The key insight: Claude Code → GitHub → Local → R. Each arrow is a separate step.