explainx.ainewsletter3.5k
TrendingNewsPathwaysSkills
Pricing
explainx.ai

Upskill in AI — 16 free pathways, live workshops & bootcamps, and 50+ courses from practitioners. Plus the skills, tools, and MCP servers to practice on.

follow us

custom AI agents

[email protected]

get started

Find your pathTake Free Evaluation

learn

pathways — start freeworkshopsbootcampscoursescertificationsmock testsexplainx universitycorporate traininglearn skills & mcp

discover

skillsmcp serversexplainx mcptoolsagentsllmsdesignsagi trackerranks

company

aboutvisionmissionteaminstructorscommunityhackathonscareers

content

daily AI newsstate of AI — live resultsblogreleasespromptsgeneratorsresource librarydemofor LLMs

solutions

all solutionsdeveloper upskillingmarketing upskillingproduct manager upskillingleadership upskilling

More from us

InfloqInfluencer marketingBgBlurPrivacy-first blurOlly SocialSocial AI copilotCeptoryVideo intelligenceBgRemoverBackground removal

newsletter · weekly

Get AI news, tools, and insights in your inbox.

supportprivacytermsdata rightssubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

On this page

  • What is version control?
  • Step 1: Install Git
  • Step 2: Configure Git with your identity
  • Step 3: Create a GitHub account
  • Step 4: Create your first local project
  • Step 5: Initialise a Git repository
  • Step 6: Stage and commit your file
  • Step 7: Create a repository on GitHub
  • Step 8: Connect your local project to GitHub
  • Step 9: Push to GitHub
  • The daily Git workflow
  • Commands you'll use most
  • What to do when something goes wrong
  • What to learn next
← Back to blog

explainx / blog

What is Git? How to Push Your First Code to GitHub (Beginner Guide 2026)

Learn what Git is, how to install it, and how to push code to GitHub — step by step. Real commands, no assumed knowledge. The complete beginner's guide to version control in 2026.

Jun 27, 2026·5 min read·Yash Thakker
GitGitHubBeginner GuideVersion ControlDeveloper Tools
go deep
What is Git? How to Push Your First Code to GitHub (Beginner Guide 2026)

Git is the tool that lets you track every change you make to your project — who changed what, when, and why. GitHub is where those changes live online so you can access them from anywhere, share them with others, or roll back to any earlier version.

Every developer uses Git, every day. This guide gets you from zero to your first pushed commit.

A full walkthrough of Git and GitHub from installation to your first push.

What is version control?

Without version control, you end up with folders like this:

snippet
project/
  index.html
  index-v2.html
  index-FINAL.html
  index-FINAL-v2.html
  index-ACTUALLY-FINAL.html

Git replaces all of that. You keep one version of your files. Git tracks every change invisibly in the background, and you can jump back to any point in the history instantly.


Step 1: Install Git

On macOS

Open Terminal (press Cmd + Space, type "Terminal", press Enter).

Check if Git is already installed:

bash
git --version

If you see a version number like git version 2.45.2, you're done. Skip to Step 2.

If not, install it with Homebrew. First install Homebrew if you don't have it:

bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Then install Git:

bash
brew install git

Verify:

bash
git --version

On Windows

  1. Go to git-scm.com/download/win
  2. Download the latest 64-bit installer
  3. Run it — accept all default settings
  4. Open Git Bash (search for it in the Start menu)
  5. Verify: git --version

Use Git Bash on Windows for all commands in this guide.


Step 2: Configure Git with your identity

Git attaches your name and email to every commit you make. Do this once:

bash
git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Replace with your actual name and the email you'll use for GitHub. Verify it saved:

bash
git config --global --list

Step 3: Create a GitHub account

Go to github.com and sign up for a free account if you don't have one. Use the same email you set in Step 2.


Step 4: Create your first local project

Create a folder for your project:

bash
mkdir my-first-project
cd my-first-project

Create a simple file inside it:

bash
echo "# My First Project" > README.md

You now have a folder with one file in it.


Step 5: Initialise a Git repository

Tell Git to start tracking this folder:

bash
git init

You'll see:

snippet
Initialized empty Git repository in /path/to/my-first-project/.git/

A hidden .git folder has been created. This is where Git stores all its tracking data. Don't touch it.


Step 6: Stage and commit your file

Check the status of your working directory:

bash
git status

You'll see README.md listed as an "untracked file" — Git can see it exists but isn't tracking it yet.

Stage the file (tell Git to include it in the next commit):

bash
git add README.md

To stage all files at once:

bash
git add .

Commit the staged files with a message describing what you did:

bash
git commit -m "Add README"

You'll see output like:

snippet
[main (root-commit) a3f1c2d] Add README
 1 file changed, 1 insertion(+)
 create mode 100644 README.md

That string (a3f1c2d) is your commit hash — a unique ID for this snapshot.


Step 7: Create a repository on GitHub

  1. Go to github.com/new
  2. Repository name: my-first-project
  3. Leave it Public (or Private — your choice)
  4. Do NOT tick "Add a README file" — you already have one
  5. Click Create repository

GitHub will show you a page with setup instructions. You only need the commands in the "push an existing repository" section.


Step 8: Connect your local project to GitHub

Copy the repository URL from the GitHub page. It looks like:

snippet
https://github.com/yourusername/my-first-project.git

Add it as the remote origin:

bash
git remote add origin https://github.com/yourusername/my-first-project.git

Rename your current branch to main (GitHub's default):

bash
git branch -M main

Step 9: Push to GitHub

bash
git push -u origin main

Git will ask for your GitHub username and password. Note: GitHub no longer accepts your account password here — you need a Personal Access Token.

To create a token:

  1. Go to github.com/settings/tokens
  2. Click Generate new token (classic)
  3. Give it a name, set expiry, tick repo scope
  4. Copy the token — you won't see it again

Use the token as your password when Git prompts you.

After a successful push, refresh your GitHub repository page. Your README.md is there.


The daily Git workflow

Once your project is set up, your day-to-day workflow is:

bash
# 1. Make changes to your files
# 2. See what changed
git status

# 3. Stage the changes
git add .

# 4. Commit with a message
git commit -m "Describe what you changed"

# 5. Push to GitHub
git push

After the first push with -u origin main, you only need git push from then on.


Commands you'll use most

CommandWhat it does
git statusShow what's changed and what's staged
git add .Stage all changed files
git add filenameStage one specific file
git commit -m "message"Save a snapshot with a description
git pushUpload commits to GitHub
git pullDownload latest changes from GitHub
git logShow commit history
git log --onelineShow commit history, condensed
git diffShow line-by-line changes not yet staged

What to do when something goes wrong

Accidentally staged the wrong file:

bash
git restore --staged filename

Want to undo your last commit (but keep the changes):

bash
git reset HEAD~1

Check where your remote is pointing:

bash
git remote -v

Clone an existing GitHub repository to your computer:

bash
git clone https://github.com/username/repo-name.git

What to learn next

Once you're comfortable with add, commit, and push, the next things to learn are:

  • Branching — git checkout -b feature-name to create a new branch
  • Merging — combining branches when work is done
  • Pull requests — the GitHub workflow for proposing and reviewing changes
  • .gitignore — a file that tells Git which files to never track (like node_modules/ or .env)

A good .gitignore for most projects:

snippet
node_modules/
.env
.DS_Store
*.log
dist/

Create it at the root of your project before your first commit.

Yash Thakker

Written by

Yash Thakker

Yash is an AI expert with over 300K learners. Join his workshops →

Related posts

Jul 31, 2026

GitHub Stacked Pull Requests: Public Preview Explained

GitHub shipped stacked pull requests to public preview — breaking large changes into an ordered series of small, reviewable PR layers, reviewable in parallel, mergeable in one operation. Available on GitHub.com, the CLI, mobile, and via the gh-stack skill for coding agents like GitHub Copilot. explainx.ai breaks down the workflow and why it matters for AI-era PR sizes.

Jul 3, 2026

GitHub Will Burn Your Public Repo to CD-ROM — The PlayStation Parody

Two days after Sony killed physical PlayStation discs, GitHub announced you can order a burned CD-ROM of your public repo. The joke is real — first 1,000 eligible submissions, July 2–6 only — and the internet noticed.

Jun 29, 2026

Commit History: GitHub's New All-Time Commit Leaderboard Explained (2026)

A new site called Commit History went viral on X in late June 2026, ranking developers by lifetime GitHub commits the way star-history.com ranks repo stars. Peter Steinberger leads combined totals at 268,000. Pieter Levels tops exposed private commits at 161,515. The leaderboard is part brag sheet, part Rorschach test for what "shipping" means when agents write half your diffs.