graph LR
WD["Working Directory"] -- "Commit (Save Snapshot)" --> LR["Local Repository"]
LR -- "Push (Upload)" --> GH["GitHub (Remote)"]
GH -- "Pull (Sync & Merge)" --> WD
style WD fill:#f9f,stroke:#333,stroke-width:2px
style LR fill:#bbf,stroke:#333,stroke-width:2px
style GH fill:#dfd,stroke:#333,stroke-width:2px
26 GitHub and Remote Collaboration
- Understand remote repositories and the role of GitHub as a central “source of truth.”
- Set up GitHub authentication directly in the Antigravity IDE (no terminal setup required).
- Master the three core Git actions: Commit, Push, and Pull.
- Use the IDE’s built-in Source Control panel to review, stage, commit, and sync changes.
- Write effective
.gitignorefiles to prevent AI agents from tracking temporary files or large biological datasets.
26.1 What is GitHub and Why Remotes?
In previous chapters, we focused on local Git—managing version control on your own machine. While this tracks history, it doesn’t allow you to share your work with collaborators, back up your code online, or synchronize your progress across different computers (e.g., your laptop and a lab desktop).
To collaborate and sync, we use a remote repository (or simply a “remote”). A remote is a version of your repository hosted on the internet. GitHub is a cloud-based hosting service for Git repositories, acting as the “single source of truth” for a project.
By default, when you link your local repository to a remote repository on GitHub, Git assigns it the default nickname origin.
For security reasons, GitHub requires secure authentication. Rather than using complex command-line steps to generate SSH key pairs manually, the Antigravity IDE manages authentication for you in a few clicks. Simply log in using the IDE’s built-in Accounts menu or search for “Sign in to GitHub” in the Command Palette.
26.2 Understanding the Core Concepts: Commit, Push, and Pull
When you work on your assignments or research projects, you will write code and ask AI agents to make edits. Git keeps track of these changes through three core concepts:
- Commit (Local Snapshot): Saves a snapshot of your files at a specific point in time only on your local computer. Think of it like taking a photo of your project to lock in your progress. Committing does not upload anything to the internet.
- Push (Upload): Uploads your local commits (snapshots) to the remote repository on GitHub. This backs up your progress to the cloud so you never lose your work.
- Pull (Download & Sync): Downloads the latest commits from the remote repository on GitHub and merges them into your local files. This is essential when working across multiple computers.
If you work on both a school desktop and a personal laptop, GitHub acts as the bridge:
- Always Pull First: The very first thing you must do when starting a work session is run a Pull. This ensures any progress you made on your other computer is merged into your active workspace.
- Commit and Push when Done: Before closing your computer, compile your code, verify it works, and then Push your changes to GitHub to save your progress.
26.4 Shielding the Repository: .gitignore
In biological research, your project folder will often contain massive raw datasets (like genomic sequence reads or large satellite images) and temporary system files.
Because AI agents can be eager to commit your work, you must set up a shield to prevent them from staging these files. We do this with a special file named .gitignore placed in the root directory.
26.4.1 Common Gotchas with .gitignore
-
It Does Not Retroactively Ignore (The “Not Working” Gotcha): If a file has already been committed to Git in the past, adding it to
.gitignorewill not work. Git will continue tracking and committing any changes to that file. To make.gitignorework, you must first untrack the file (see the Tip below). -
No Direct Size Filtering: A
.gitignorefile filters by file name patterns (like*.csv), not by file size. However, GitHub has a strict size filter that rejects any push containing a file larger than 100 MB (and warns you for files over 50 MB). If you accidentally download a huge dataset file that is not matched by your.gitignorepatterns, Git will try to track it.-
Tip: Find large files in your terminal: You can search your project for any files larger than 50 MB by running:
find . -type f -size +50M
-
26.4.2 A Best-Practice .gitignore for R Biologists
Create a text file named .gitignore in your repository root and add the following:
.Rhistory
.RData
.Ruserdata
.Rproj.user/
.DS_Store
Thumbs.db
If you accidentally committed a large file before adding it to your .gitignore, Git will keep tracking it. Tell Git to stop tracking it without deleting it from your computer by running:
git rm --cached data/large_dataset.csvAlternatively, you can just ask your AI agent to do it:
“Stop tracking data/large_dataset.csv in Git, but keep the file on my computer.”