Skip to main content

Never Lose Your Coding Flow Again Using Git

May 20, 2026

In this walkthrough, you’ll learn how to keep your coding progress safe with Git. We’ll cover eight essential commands and create your first commit.

Who This Is For

  • Self-taught developers who skipped formal CS training
  • Claude users looking to save tokens
  • Cursor users who want to retain their work

What You’ll Create

  • A basic Git-enabled project with version tracking
Step 1 Install Git.webp

Getting Started Requirements

  • A computer with terminal/command line access
  • A code editor or IDE (we use Cursor)

Step 1: Install Git

Go to git-scm.com.

  • On Windows: download and run the installer
  • On Mac: install via Homebrew

Both Homebrew and Git are safe, open-source tools with long-standing use.

To confirm installation, run:

git --version

Step 2: Initialize Git in Your Project

Open your editor and create a new folder with a simple HTML file (or use a sample).

Start a terminal in your editor and run:
git init

This enables change tracking in your project.

💡 Tip: Ask your AI coding assistant to generate a README.md explaining your project—it’s useful when uploading to GitHub.

Step 3: Make Your First Commit

A commit is a saved snapshot of your code. Each one includes:

  • A unique ID (e.g., abc1234def5678)
  • A message describing changes
  • The author
  • A timestamp

First, stage your changes:
git add .

Then create a commit:
git commit -m 'first commit!'

Step 3 Make Your First Commit.webp

Your changes are now saved to the main branch.

Step 4: Create a Feature Branch

Using separate branches for features helps avoid issues and improves workflow clarity.

Create a branch:
git checkout -b feature-1

Now commits go to this branch.

To view branches:
git branch

To switch branches:
git checkout [branch name]

Step 4 Create a Feature Branch.webp

Step 5: Merge Changes into Main

Add changes in your feature branch and commit them.

Switch back to main:
git checkout main

Merge your branch:
git merge feature-1

Your updates are now part of the main branch.

Step 4 Create a Feature Branch.webp

💡 Tip: Use git log to view commit history. To undo a merge, use:
git reset [commit hash

Step 6: Let AI Handle Git Workflows

When starting a project, add rules like this to your context file (e.g., CLAUDE.md for Claude):

Git Rules

1. Create feature branch: `git checkout -b feature-[name]`

2. Commit after each logical change: `git commit -m "Add [what you did]"`

3. When done, ask: "Ready to merge feature-[name] into main?"

4. Wait for approval before merging

5. Never commit directly to main

Going Further

To push your code online, install GitHub CLI and authenticate with:
gh auth login

Create a repository on GitHub, then run the provided commands in your terminal.

To upload a branch anytime:
git push origin [branch name]

Going Further.webp
Editorial Staff

Editorial Staff

The Editorial Staff at AIChief is a team of Professional Content writers with extensive experience in the field of AI and Marketing. AIChief was Founded in 2025, AIChief has quickly grown to become the largest free AI resource hub in the industry. Stay connected with them on Facebook, Instagram and X for the latest updates.

View All Posts

User Comments

Filter:
No comments yet. Be the first to comment!