GitHub for Data Professionals: Your First Repository and the Pull Request Workflow
Git records every change to your SQL on your own computer, and GitHub hosts that history so a team can review it. A first-repository walkthrough for a data project, with real output.
On this page · 21 sections
- Git vs GitHub
- Set up your first repository for a data project
- 1. Initialize the repository
- 2. Add the project files and a .gitignore
- 3. Make the first commit
- 4. Create a branch and commit to it
- 5. Put the repository on GitHub
- A .gitignore for data work
- The branch, commit, pull request, review, merge workflow
- Why analytics teams work this way
- What belongs in a README for a data project
- Everyday situations and what to do
- Continuous integration with GitHub Actions
- GitHub and the job search
- Common mistakes
- Frequently Asked Questions
- How do I initialize a new Git repository for a data project?
- What is the process to push an existing local project to a new GitHub repository?
- How do I handle large data files within GitHub repositories?
- How can I collaborate effectively with team members on data analysis projects using GitHub?
- Primary sources and further reading
- Category
- Git
GitHub for data professionals comes down to two tools: Git, version control software that records every change to your SQL files on your own computer, and GitHub, a website that hosts that history so a team can review and merge each other's changes. To set up a GitHub repository for a data project, initialize Git in the project folder, add a .gitignore file that keeps data extracts and credentials out, commit, and push to an empty repository on GitHub. This guide runs those steps on an example project, shows the output Git printed, and covers the pull request workflow data analysts meet on a team.
Git vs GitHub
Git is a distributed version control system: it tracks the history of changes to a project so any earlier version can be recovered, and every person has a full copy of that history. According to the Pro Git book on git-scm.com, each commit stores a snapshot of your files, and nearly every operation is local, so you can commit with no network connection.
GitHub's documentation describes GitHub as a platform based on Git that hosts Git projects, called repositories, in the cloud and adds collaboration tools. A repository holds a project's files and each file's revision history.
| Question | Git | GitHub |
|---|---|---|
| What it is | Version control software | A hosting and collaboration platform built on Git |
| Where it runs | On your computer | On github.com |
| What it gives you | Commits, branches, merges, full history | A shared copy of the repository, pull requests, code review, GitHub Actions |
Set up your first repository for a data project
The example is a small dbt project called shop-analytics. A dbt model is a SQL SELECT statement that dbt builds into a table or view. The same steps work for a folder of plain SQL. Every command was run with Git 2.48.1. Lines starting with $ are commands. The rest is what Git printed, with the folder path replaced by /path/to. Your commit hashes will differ.
1. Initialize the repository
$ mkdir shop-analytics
$ cd shop-analytics
$ git init -b main
Initialized empty Git repository in /path/to/shop-analytics/.git/
$ git config user.name "Ana Analyst"
$ git config user.email "ana@example.com"
git init adds a hidden .git folder that holds the history, and -b main names the first branch. The git config commands set the name and email address Git attaches to every commit, for this repository only. GitHub's documentation also describes a --global option that covers every repository on the computer.
2. Add the project files and a .gitignore
The layout follows dbt Labs' guide: models split into staging and marts, seeds for small reference CSV files, dbt_project.yml, and a README (see dbt project structure best practices). To test the ignore rules, the folder also holds files that must not be committed: .env, profiles.yml, a CSV extract in data/, and target/ and logs/ folders like the ones dbt writes. With the .gitignore from the next section in place, Git sees only the project files:
$ git status --short --untracked-files=all
?? .gitignore
?? README.md
?? dbt_project.yml
?? models/staging/stg_orders.sql
?? seeds/country_codes.csv
?? means untracked.
3. Make the first commit
$ git add .
$ git commit -m "Add project skeleton and staging model"
[main (root-commit) 9534c2c] Add project skeleton and staging model
5 files changed, 52 insertions(+)
create mode 100644 .gitignore
create mode 100644 README.md
create mode 100644 dbt_project.yml
create mode 100644 models/staging/stg_orders.sql
create mode 100644 seeds/country_codes.csv
git add stages changes for the next commit, and git commit saves the snapshot. git add . stages everything not ignored, which is safe here because the status output listed exactly five files. When unsure, stage files by name, as GitHub advises to avoid committing secrets.
4. Create a branch and commit to it
A branch is a separate line of development, so the new model stays off main until it is merged. Create one, add the model file in your editor, then stage and commit it:
$ git switch -c add-daily-revenue
Switched to a new branch 'add-daily-revenue'
$ git add models/marts/daily_revenue.sql
$ git commit -m "Add daily revenue mart"
[add-daily-revenue 7255578] Add daily revenue mart
1 file changed, 5 insertions(+)
create mode 100644 models/marts/daily_revenue.sql
$ git log --oneline
7255578 Add daily revenue mart
9534c2c Add project skeleton and staging model
5. Put the repository on GitHub
This step happens on github.com and was not run. GitHub's documentation gives the procedure: from the menu in the upper-right corner of any page, click New repository, select an owner, type a name, choose a visibility (public repositories are accessible to everyone on the internet), and click Create repository. To avoid errors, GitHub says not to initialize it with a README, license, or gitignore file. Copy the repository URL from the Quick Setup page and connect your local repository:
$ git remote add origin https://github.com/YOUR-USERNAME/shop-analytics.git
$ git remote -v
origin https://github.com/YOUR-USERNAME/shop-analytics.git (fetch)
origin https://github.com/YOUR-USERNAME/shop-analytics.git (push)
Those two commands were run with a placeholder URL. The final command in GitHub's guide, git push -u origin main, uploads the commits. It was not run because it needs a real repository and GitHub authentication. Push a branch the same way, with its name in place of main. To join an existing project instead, GitHub's documentation uses git clone.
A .gitignore for data work
A .gitignore file in the repository's root directory tells Git which files and folders to leave out. Commit it so everyone who clones the repository gets the same rules. This is the one used above:
# Data extracts stay out of the repository
data/
*.csv
!seeds/*.csv
# Credentials
.env
profiles.yml
# dbt output, logs, and installed packages
target/
logs/
dbt_packages/
data/and*.csv. Extracts are large and often contain customer data. Data belongs in the warehouse.!seeds/*.csv. The!re-includes files an earlier pattern excluded. dbt seeds are small reference CSV files that dbt's documentation describes as version controlled. It says not to use them for raw exports..env. dbt's documentation says to add.env, where local environment variables are kept, to.gitignoreto keep credentials out of version control.profiles.yml. It holds dbt's warehouse credentials. dbt recommends keeping it in~/.dbt/, outside the project. The rule covers a copy that ends up inside.target/,logs/,dbt_packages/. dbt writes artifacts, logs, and installed packages there, and its documentation lists all three as entries a project's.gitignoreneeds.
To see which rule decides a path, ask Git:
$ git check-ignore -v data/orders_export.csv
.gitignore:2:data/ data/orders_export.csv
$ git check-ignore -v seeds/country_codes.csv
.gitignore:4:!seeds/*.csv seeds/country_codes.csv
The branch, commit, pull request, review, merge workflow
GitHub calls this GitHub flow. A pull request is a request to merge the changes on one branch into another.
- Branch. Create a branch with a short, descriptive name.
- Commit and push. Make each commit one isolated, complete change with a descriptive message.
- Open a pull request. On the repository's main page, choose your branch in the Branch menu, click Compare & pull request, select the base branch, type a title and description, and click Create Pull Request.
- Review. Reviewers comment on the pull request or on specific lines and submit a decision: Comment, Approve, or Request changes.
- Merge. Once approved, merge the pull request so the changes appear on the default branch, then delete the branch.
A branch protection rule can require approving reviews and passing status checks before anything merges into main. For the commands themselves, see the top 10 Git commands for data professionals.
Why analytics teams work this way
A model change alters numbers that other people report. Review puts a second person in front of a changed join or filter before a dashboard moves, and the pull request records why a metric definition changed. If production builds only from a protected main, it runs only reviewed code.
What belongs in a README for a data project
GitHub shows a repository's README to visitors, and says one typically covers what the project does, why it is useful, how to get started, where to get help, and who maintains it. For a data project, make that concrete:
- What it produces. The tables or reports and the questions they answer.
- Data sources. What it reads, how often that refreshes, and where the data lives.
- Setup and run. Tools, connection setup, and the commands to build and test.
- Layout. What each folder holds and how models are named.
- Owner. Who to ask.
Everyday situations and what to do
| Situation | What to do |
|---|---|
| You want to discard uncommitted edits | git restore models/staging/stg_orders.sql. The edits are gone for good. |
| The last commit message has a typo, not pushed | git commit --amend -m "Document the daily revenue model in the README" |
| Undo the last commit, keep the work, not pushed | git reset --soft HEAD~1. The changes stay staged. |
| Undo a commit already on GitHub | git revert --no-edit HEAD. Adds a new commit that reverses the last one. |
| A large CSV went into the last commit with other work, not pushed | git rm --cached seeds/orders_export.csv, then git commit --amend -CHEAD, as GitHub documents. The file stays on disk. Move it to an ignored folder. |
| Two people changed the same model | git merge main reports CONFLICT (content): Merge conflict in models/staging/stg_orders.sql. Edit the file, delete the <<<<<<<, =======, and >>>>>>> markers, then run git add models/staging/stg_orders.sql and git commit -m "Merge main into add-daily-revenue". |
| You committed a password or key | Revoke or rotate it first, which GitHub says may be sufficient. Removing it from history needs coordination with everyone who has a clone. |
For a file added in an earlier commit, GitHub recommends the git filter-repo tool.
Continuous integration with GitHub Actions
GitHub's documentation describes GitHub Actions as a continuous integration and continuous delivery (CI/CD) platform that automates build, test, and deployment pipelines. A workflow is a YAML file in the repository's .github/workflows directory that runs when an event occurs, such as a pull request being opened. How to implement CI/CD for your analytics projects covers what to run.
GitHub and the job search
A public repository with a clear README and a readable commit history shows how you work. Optimizing your GitHub profile for analytics roles covers the profile, and analytics engineering portfolio projects suggests what to build. For a first dbt project, follow the dbt tutorial for beginners.
Common mistakes
- Writing the .gitignore after the first commit. Ignore rules do not affect files Git already tracks. Untrack them with
git rm --cachedfirst. - Treating a deleted secret as safe. Deleting the file in a later commit leaves it in the history. Rotate it.
- Committing straight to main. Nobody reviews the change, and no pull request explains it.
- Amending or resetting pushed commits. Pro Git says to amend only commits that are still local. Use
git revertfor shared ones.
Frequently Asked Questions
How do I initialize a new Git repository for a data project?
Run git init -b main in the project folder, add a .gitignore before you stage anything, then run git add and git commit.
What is the process to push an existing local project to a new GitHub repository?
Create the repository on GitHub without a README, license, or gitignore file. Then run git remote add origin with its URL, followed by git push -u origin main.
How do I handle large data files within GitHub repositories?
Keep them out. As of November 2026, GitHub's documentation says Git warns about files larger than 50 MiB, GitHub blocks files larger than 100 MiB, and repositories should ideally stay under 1 GB. Git Large File Storage can track bigger files, but analytics data usually belongs in the warehouse.
How can I collaborate effectively with team members on data analysis projects using GitHub?
Use one shared repository, one branch per change, and a pull request for every change to main. Keep pull requests small, say what changed and why, and require an approving review with a branch protection rule.
Primary sources and further reading
- What is Git? and Undoing Things, Pro Git. Snapshots, local operations, amending.
- gitignore, git-revert, and git-push, Git documentation. Ignore patterns, reverts, pushing a branch.
- What is GitHub? and About Git, GitHub Docs. The definitions.
- Adding locally hosted code to GitHub, Creating a new repository, About repositories, and Setting your username in Git, GitHub Docs. Steps 1 and 5.
- Ignoring files, Removing sensitive data from a repository, and About large files on GitHub, GitHub Docs. Ignore files, committed secrets, size limits.
- GitHub flow, Creating a pull request, Pull request reviews, and About protected branches, GitHub Docs. The workflow.
- About the repository README file and Understanding GitHub Actions, GitHub Docs. README contents and the Actions definition.
- About profiles.yml, How can I fix my .gitignore file?, Logs, Packages, and Seeds, dbt documentation. The dbt ignore entries.
- SQL models and How we structure our dbt projects, dbt documentation. Models and layout.
Commands were run with Git 2.48.1. Documentation was read in November 2026.
- Git
GitHub for Data Professionals: Your First Repository and the Pull Request Workflow
Git records every change to your SQL on your own computer, and GitHub hosts that history so a team can review it. A first-repository walkthrough for a data project, with real output.
- Git
Optimizing Your GitHub Profile for Analytics Roles: Proven Strategies
Learn to optimize your GitHub profile for analytics roles. Discover strategies for impactful projects, effective documentation, and community engagement.
- Git
Top 10 Git Commands for Data Professionals: Key Concepts & Best Practices
Discover 10 essential Git commands tailored for data professionals. Learn how to manage code, track changes, and collaborate effectively on data projects.
