Which Git Workflow Are You In? A Complete Guide to Every Git Situation
If you’ve ever Googled “how to push my project to GitHub” for the fifth time, this guide is for you. Git workflows depend entirely on where you are right now — not where you want to be. Instead of memorizing random commands, identify your situation from the five below, follow the steps, and move on with your life.
Here 5 situations wearing different outfits.
1. Starting a New Project
You’re starting a project from scratch. Git has not been initialized yet and there is no repository on GitHub.
Your situation: A blank folder and a dream.
Step 1 — Initialize Git locally
Navigate to your project folder and initialize a Git repository:
bash
mkdir my-awesome-project
cd my-awesome-project
git initThis creates a hidden .git folder — Git is now tracking your project.
Step 2 — Create a .gitignore
Before your first commit, tell Git which files it should ignore (build artifacts, .env files, node_modules, etc.):
bash
touch .gitignoreAdd entries like:
node_modules/
.env
*.log
dist/💡 Pro tip: Visit gitignore.io to generate a ready-made
.gitignorefor your tech stack.
Step 3 — Create the repository on GitHub
Go to GitHub → click New Repository → give it a name → don’t initialize with a README (you already have files locally).
Step 4 — Connect and push
Link your local repo to the remote one and push:
bash
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/your-username/my-awesome-project.git
git push -u origin main✅ You’re done. Your project is now version-controlled locally and backed up on GitHub.
2. Local Project → GitHub
You have already built your project on your local machine and now want to push it to GitHub.
Your situation: A working project on your laptop that nobody else can see. Time to change that.
Step 1 — Verify Git is initialized
Check if Git already exists in the project:
bash
git statusIf you see fatal: not a git repository, initialize it first:
bash
git initStep 2 — Stage and commit everything
bash
git add .
git commit -m "Initial commit"If the project is large, add a .gitignore before running git add . — otherwise you'll accidentally commit thousands of node_modules files.
Step 3 — Create the GitHub repository
On GitHub, create a new empty repository (again, skip the README/license options if you have existing files).
Step 4 — Connect remote and push
bash
git branch -M main
git remote add origin https://github.com/your-username/your-repo.git
git push -u origin main⚠️ Common mistake: Running
git remote add origintwice will throw a "remote origin already exists" error. If that happens, rungit remote remove originfirst, then add it again.
✅ You’re done. Your local project is now live on GitHub.
3. GitHub → Local Machine
An existing project is already on GitHub, and you want to clone it to your local machine and start working on it.
Your situation: You found a repo (yours or your team’s) and want it on your machine.
Step 1 — Copy the repository URL
On the GitHub repo page, click the green Code button and copy the URL.
Step 2 — Clone the repository
bash
git clone https://github.com/username/repository-name.gitThis downloads the entire project history and creates a folder named after the repo.
Thirty seconds of git clone, and you're in. Compare that to the old days of downloading ZIP files like a caveman.
Step 3 — Enter the project
bash
cd repository-nameStep 4 — Install dependencies and verify
bash
# If it's a Node.js project
npm install# If it's a Python project
pip install -r requirements.txt✅ You’re done. You now have a fully working copy of the project on your machine.
4. Contributing to a Remote Project
You want to make changes to an existing remote project and create a Pull Request to propose your changes.
Get It's_Vani’s stories in your inbox
Join Medium for free to get updates from this writer.
Your situation: You’re contributing to an open-source project or a teammate’s repo. You don’t have write access to main — and that's a good thing.
Step 1 — Fork the repository
On GitHub, click the Fork button (top right). This creates a copy of the repo under your account.
Step 2 — Clone your fork
bash
git clone https://github.com/your-username/forked-repo.git
cd forked-repoStep 3 — Add the original repo as upstream
bash
git remote add upstream https://github.com/original-owner/original-repo.gitThis lets you pull future updates from the original project.
Step 4 — Create a feature branch
Never work directly on main.
bash
git checkout -b feature/add-dark-modeStep 5 — Make changes and commit
bash
git add .
git commit -m "Add dark mode toggle"Step 6 — Push your branch to your fork
bash
git push origin feature/add-dark-modeStep 7 — Open a Pull Request
On GitHub, navigate to your fork → click “Compare & pull request” → write a clear description of what you changed and why → submit.
💡 Pro tip: A good PR description has three parts: what the change does, why it’s needed, and how to test it.
Maintainers don’t remember your code. They remember your PR descriptions. (Okay, they remember neither — but good descriptions still get merged faster.)
✅ You’re done. Your changes are now proposed for review and merge.
5. Getting the Latest Changes
You’re already working on a project with other developers, and they have pushed new changes to the remote repository. You want to bring those changes into your local project.
Your situation: Your teammate merged a PR while you were working. Your local code is now outdated.
Step 1 — Save your current work first
Before pulling, make sure your working directory is clean:
bash
git statusIf you have uncommitted changes, commit or stash them:
bash
# Option A: Commit your work
git add .
git commit -m "WIP: my current changes"# Option B: Stash it for later
git stashStep 2 — Switch to the main branch
bash
git checkout mainStep 3 — Pull the latest changes
bash
git pull origin mainStep 4 — Sync your feature branch (if you’re working on one)
bash
git checkout feature/my-feature
git merge mainOr, to keep history cleaner:
bash
git rebase main⚠️ Merge conflict? Don’t panic. Git will mark the conflicting files with
<<<<<<<,=======, and>>>>>>>markers. Open the files, manually resolve the conflicts, then:
bash
git add .
git commit -m "Resolve merge conflicts"Step 5 — Restore your stashed work (if you stashed)
bash
git stash pop✅ You’re done. Your local project is now in sync with the remote.
The Cheat Sheet
Table
SituationKey Commands1. New projectgit init → git add . → git commit → git remote add origin → git push -u origin main2. Local → GitHubgit add . → git commit → git remote add origin → git push -u origin main3. GitHub → Localgit clone <url>4. Contribute (PR)Fork → clone → git checkout -b feature/x → commit → push → open PR5. Get latest changesgit stash → git checkout main → git pull origin main
Final Thoughts
You’ve now officially Googled your last Git question. (Okay, that’s a lie — but at least now you’ll know what to search.)
Git feels overwhelming until you realize it’s just a handful of workflows repeated over and over. Bookmark this guide, identify which of the five situations you’re in, and follow the steps. Before long, you won’t need the guide at all.
Which workflow do you find yourself in most often? Let me know in the comments — and if this saved you a Google search (or five), share it with a developer friend who needs it. 🚀
If you enjoyed this article, follow me for more practical developer guides — written so you never have to memorize a command again.





