Git basics
Git keeps a history of your code and moves it between computers. This page takes you from a folder of code to your first git push, with a .gitignore file that keeps dependencies, build output, and secrets out of it.
Last updated
AI agent? Start with llms.txt.
What Git is
Git records versions of the files in one folder. Each version is a commit, a snapshot of every file with a short note about what changed, and the folder with its history is a repository. When you push, Git sends your new commits to another copy of the repository, such as one on Tokay or GitHub. That copy then has exactly what you committed, file for file.
You don't need Git to use Tokay. Paste or upload your code as in Your first deploy, and Tokay keeps a Git history of it for you, which you can clone later. Git pays off once you change code on your own computer or an AI agent edits it with you, because every change is recorded and you can go back to any earlier version.
Install Git
Open Terminal on macOS or PowerShell on Windows and check whether Git is already there.
git --version
A version number means you're ready. Otherwise install it.
- On macOS, the same command offers to install Apple's command line developer tools, which include Git. Accept, then run
git --versionagain. - On Windows, download Git for Windows from git-scm.com and run the installer with its default options. Open a new PowerShell window afterwards so it finds Git.
Git writes your name and email into every commit, so set them once.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
Leave files out with .gitignore
A .gitignore is a plain text file in the top folder of your code. Each line names a file or folder that Git leaves out of every commit. Write it before your first commit, because it does not remove anything Git already recorded.
Three kinds of files belong in it.
- Dependencies, such as
node_modulesfor Node.js or.venvfor Python. Tokay installs your dependencies frompackage.json,requirements.txt, and similar files when it builds your app, so committing them only makes every push slower. - Build output, such as
distorbuild. Tokay runs your build itself, so a committed copy goes stale. - Secrets, such as a
.envfile. Anyone who can read your code can read a committed file. Store those values as Secrets in Tokay instead, and commit a.env.examplewith the names and no values if you want a record of what the app needs. Tokay warns you when a push includes a.envfile.
This covers the common cases for Node.js and Python, plus the files macOS and Windows add on their own.
# Dependencies
node_modules/
.venv/
venv/
__pycache__/
# Build output
dist/
build/
# Secrets
.env
.env.*
!.env.example
# System files
.DS_Store
Thumbs.db
A line ending in / matches only a folder. A line starting with # is a comment. A line starting with ! brings back a file that an earlier line left out, so .env.example stays in.
The same file shapes uploads. When you upload a folder, Tokay leaves out what its .gitignore lists, and skips node_modules, .venv, and venv folders inside it on its own.
Create a .gitignore when your computer hides it
macOS hides files whose names start with a dot, and Windows tends to save a new text file as .gitignore.txt. A code editor or the terminal avoids both problems.
- In VS Code or Cursor, open your code's folder, use the new file button at the top of the file sidebar, and name the file
.gitignore. Both editors show dot files. - On macOS, run
touch .gitignorein Terminal from your code's folder, thenopen -e .gitignoreto edit it in TextEdit. To see dot files in Finder, press Command, Shift, and period together. Press them again to hide the files. - On Windows, run
New-Item .gitignorein PowerShell from your code's folder, thennotepad .gitignoreto edit it. If you save from Notepad's own dialog, set Save as type to All files so the name stays.gitignore. In File Explorer, turn on File name extensions under View to check the name.
Make your first commit
Run these in Terminal or PowerShell after moving into your code's folder with cd. A code editor's built-in terminal opens there already.
git init
git add .
git commit -m "First version"
git init turns the folder into a repository. git add . picks up every file except the ones .gitignore lists. git commit records them as your first version.
Run git status before you commit and read the list of files. If node_modules, .env, or a build folder appears, add it to .gitignore and run git add . again.
Send your code to Tokay
With a commit in place, add Tokay as a destination and push. Deploy from Git walks through it, and SSH keys and git tokens covers the credential your first push needs.
Later, record each change with git add . and git commit, then push again. Tokay analyzes every push and prepares an update for the same Services.
Fix a file you committed by mistake
Adding a name to .gitignore leaves a file Git already records in place. Tell Git to stop tracking it, then commit. The file stays on your computer.
git rm -r --cached node_modules
git commit -m "Stop tracking node_modules"
A committed secret is different, because it stays readable in the earlier commit. Replace it at the service that issued it, such as by creating a new API key, save the new value as a Secret in Tokay, and stop tracking the file the same way.
Limits
Your code can hold up to 50,000 files, each up to 100 MB. A push can carry more than an upload, so a project that is too big to upload often still fits through Git.
| Limit | Paste or upload | Git push |
|---|---|---|
| Size | 1 GB per upload | 2 GB of Git data per push |
| Files | 10,000 per upload | 50,000 in your code |
| Largest file | 100 MB | 100 MB |