
Image by Author
# Introduction
I have been hearing stories about Claude Code or Cursor “deleting the database” or wiping out files that people have spent days building while vibe coding. The real issue is usually not the artificial intelligence (AI) itself but the lack of version control. If you are not using Git, all your work exists in a single, fragile state, and one bad refactor can wipe out everything you have done.
I even asked Claude to “set up Git and commit major changes,” but it mostly ignored my request to keep the app running. This means you can’t really rely on AI to track changes and restore the app if anything goes wrong.
This article aims to address that concern. It provides a beginner-friendly, zero-background guide for integrating Git into your vibe coding workflow. By learning simple Git commands, you will be able to create safe snapshots, perform easy rollbacks, manage clean branches, and set up automatic backups on GitHub. Keep making progress without the stress.
# 0. One-Time Setup (Tell Git Who You Are)
Go to the Git website and install the Git program based on your operating system. Then open the terminal and type:
Configure the name and email that Git will record in your commit metadata:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
These settings associate your commits with your identity, which helps Git properly track your work.
# 1. Start Tracking Your Project
Before typing claude in your terminal, navigate to the project folder and run the following command to initialize the Git repository:
After that, Git will start to track the changes you have made.
# 2. Save Your First Version (Two Steps)
Once you have made some changes, you need to save them in Git.
First, stage everything you changed, then commit it with a short message describing what you did:
git add .
git commit -m "first commit"
The command git add . means “include all changed files,” and git commit saves a snapshot with your message.
You will repeat this often as you work and ask AI to build you new features:
git add .
git commit -m "describe what you changed"
# 3. Push to GitHub
I highly recommend creating a GitHub account and then setting up a new repository there. Copy the repository URL, which will look like this: https://github.com/yourusername/my-project.git.
Next, link your local folder to that repository and push your changes using the following commands:
git branch -M main
git remote add origin https://github.com/you/my-project.git
git push -u origin main
On your first push, Git may prompt you to sign in; use your GitHub username and a Personal Access Token (PAT). You can create a PAT by going to GitHub → Settings → Developer settings → Tokens. Once you enter your credentials, they will be saved in your system’s credential manager, so for subsequent pushes, you can simply use git push.
# 4. The Daily Coding Loop
This is the cycle you will use every day:
- Do some work
- Save your changes in Git
- Send them to GitHub
git add .
git commit -m "describe the change"
git push
If the project was changed somewhere else (another person or another computer), pull first to get the latest version:
Then continue working as usual.
# 5. Create a Safe Playground (Branches)
Branches are just separate work areas so you don’t break main. Make one for each feature or fix, do your work there, then merge when ready.
git checkout -b feature-login # create + switch to a new branch
# ...code, code, code...
git add . # stage your changes
git commit -m "add login page" # save a snapshot on this branch
git push -u origin feature-login # publish branch + set upstream
When it’s ready, merge it via Pull Request on GitHub (Click “Compare & pull request”), which is best for review and history.
Or merge locally:
git checkout main # switch to main
git pull # get latest main
git merge feature-login # bring your branch into main
git push # upload updated main
Optional clean-up (after merging):
git branch -d feature-login # delete local branch
git push origin --delete feature-login # delete remote branch
# 6. Quick Fixes for Common Issues
To check the status of your repository, run:
If you are not ready to commit your changes but need to switch tasks, you can stash your changes and retrieve them later using:
Later, you can bring back your stashed changes with:
If you want to undo your last commit without losing your files (so that you can make adjustments and recommit), use:
To discard local edits to a specific file and restore it from the last commit, run:
git restore <path/to/file>
If any of these commands feel risky, you can always stick to the simple workflow of git add, git commit, and git push to ship your changes.
# 7. Minimal Cheat Sheet
For the very first setup of a new project, initialize Git, save your first snapshot, set the main branch, connect to GitHub, and push:
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/you/my-project.git
git push -u origin main
For daily work, pull the latest changes, stage your edits, commit with a clear message, and push:
git pull
git add .
git commit -m "your message"
git push
For a new feature or fix, create and switch to a branch, make changes, commit, and publish the branch to GitHub:
git checkout -b feature-name
# ...edit files...
git add .
git commit -m "implement feature"
git push -u origin feature-name
# Summary
Think of your project like a notebook:
- git add: Choose which pages you want to save (select the changes)
- git commit: Take a photo of those pages (save a snapshot with a message so you remember what happened)
- git push: Upload that photo to the cloud (send your saved work to GitHub)
- git pull: Download the newest photo from the cloud (retrieve the latest work that you or someone else uploaded)
The workflow is straightforward:
- add → commit → push
- pull → add → commit → push
This covers about 90% of what you need to know about Git. Everything else — like branches, merges, stashes, resets, etc. — are just additional tools that come in handy as your projects grow.
You don’t need to memorize every detail about Git to be productive. You will become more familiar with it naturally as you continue building.
If you remember just this, you’ll be fine:
git add .: Select my changes.git commit -m "": Save snapshot.git push: Upload.git pull: Get new updates.
Once this process feels intuitive, using Git will stop feeling daunting; it will simply become a natural part of your workflow.
Abid Ali Awan (@1abidaliawan) is a certified data scientist professional who loves building machine learning models. Currently, he is focusing on content creation and writing technical blogs on machine learning and data science technologies. Abid holds a Master’s degree in technology management and a bachelor’s degree in telecommunication engineering. His vision is to build an AI product using a graph neural network for students struggling with mental illness.