Git and GitHub for Analysts
Git looks like a wall of scary commands, but as an analyst you only need a small, repeatable core: save your work with a note, and send it to GitHub so it is backed up and shareable. That is 90% of what you will ever do. This guide teaches that core, then shows how to start a project and publish it as a live web page, and finally lists the handful of errors that trip up everyone the first time.
- Install Git and sign in once
- The everyday loop: status, add, commit, push
- Start a brand-new project and put it on GitHub
- Publish it as a live site with GitHub Pages
- What NOT to commit (and how)
- Fix the five errors everyone hits once
Step 1 — Install Git and set your identity (once)
- Install Git from git-scm.com/downloads (all defaults are fine).
- Optionally install the GitHub CLI from cli.github.com. It makes creating repos and signing in much easier.
- Open a terminal (Git Bash on Windows, Terminal on Mac) and tell Git who you are. This name and email get stamped on every save:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
If you installed the GitHub CLI, sign in to GitHub once with gh auth login and follow the prompts. This is what lets you push without pasting a password every time.
Step 2 — The everyday loop (this is 90% of Git)
Every time you finish a chunk of work, you do the same three-beat move: stage, save, send. In a terminal opened inside your project folder:
git status # see what changed (read this first, always)
git add . # stage every changed file for the next save
git commit -m "Add churn analysis notebook" # save, with a short note
git push # send it up to GitHub
That is the whole daily rhythm. status shows you what is about to be saved, add chooses the files, commit saves a snapshot with a message, and push uploads it. Do this often, with clear messages. Think of each commit as a labeled save point you can return to.
Step 3 — Start a brand-new project and put it on GitHub
You have a folder with your work in it and you want it on GitHub. From inside that folder:
git init -b main # start tracking this folder, on a branch called main
git add . # stage everything
git commit -m "First commit" # your first save point
Now create the online home for it. The easy way, with the GitHub CLI, does it in one line and pushes at the same time:
gh repo create my-project --public --source=. --remote=origin --push
No CLI? Create an empty repository on github.com/new (do not add a README, keep it empty), then copy the two commands GitHub shows you under "push an existing repository." They look like this:
git remote add origin https://github.com/yourname/my-project.git
git push -u origin main
Step 4 — Publish it as a live website (GitHub Pages)
If your project has an index.html, GitHub can host it as a real, shareable web page for free. On the repo's page: Settings → Pages → Source: Deploy from a branch → Branch: main / (root) → Save.
Wait one to two minutes for the first build, then visit:
https://yourname.github.io/my-project/
Step 5 — What NOT to commit
Git is for your code and small files, not giant datasets. GitHub rejects files over 100 MB, and committing a 2 GB CSV or a database file is a mistake either way. You exclude files by listing them in a .gitignore file in your project root:
# .gitignore
*.db # SQLite databases
*.csv # large raw data
data/raw/ # a whole folder of source files
node_modules/ # dependencies
The rule of thumb: commit the things needed to rebuild the project (code, a small sample file, a README), not the heavy data itself. Anyone can re-download or regenerate the big files.
The five errors everyone hits once
1. "Updates were rejected... fetch first"
Your push bounced because GitHub has changes your computer does not (common if you edited a file on the website, or work on two machines). Pull first, then push:
git pull --rebase
git push
2. It asks for a password and rejects it
GitHub stopped accepting account passwords over Git in 2021. Either sign in once with gh auth login (easiest), or create a Personal Access Token (GitHub → Settings → Developer settings → Personal access tokens) and paste that token where it asks for a password.
3. "warning: LF will be replaced by CRLF"
Harmless. It is just Git noting that Windows and Mac/Linux mark line-endings differently. Your files are fine. Ignore it.
4. You committed a huge file by accident
Add it to .gitignore, then stop tracking it (this removes it from Git but keeps it on your disk):
git rm --cached bigfile.csv
git commit -m "Stop tracking large data file"
5. "fatal: not a git repository"
You are running Git in a folder that was never started with git init, or you are one folder too high or too low. Check where you are, and make sure you are inside the project folder.
Cheat sheet
| Goal | Command |
|---|---|
| See what changed | git status |
| Save your work | git add . then git commit -m "message" |
| Send it to GitHub | git push |
| Get others' changes first | git pull --rebase |
| Start tracking a folder | git init -b main |
| Create + push a new repo (CLI) | gh repo create name --public --source=. --push |
| Stop tracking a file | git rm --cached file |
The free Portfolio Projects track walks you through building analyst projects end to end, and the SQL Kit gives you the analysis skills to fill them. Git is how you ship them.
Open Portfolio Projects →