explainx.ainewsletter3.4k
trending🔥loopsskills
pricing
workshops ↗
explainx.ai

Learn to lead teams that combine humans and agents. Platform access, live workshops, bootcamps, and 50+ courses — plus skills, tools, and MCP to practice what you learn.

follow us

custom AI agents

[email protected]

get started

Join · $29/mo

learn

start for freepathwaysworkshopsbootcampscoursescertificationscertification testsexplainx universitycorporate trainingfacilitatorshackathonslearn skills & mcp

discover

skillstoolsagentsmcp serversdesignsllmsagiranks

content

releasesvisionmissionaboutcommunityteamcareersresourcespromptsgenerators hubgenerator SEO hubprompt templatesprompt guidesblogfor LLMsdemo

Sister Products

Infloq

Infloq

Influencer marketing

BgBlur

BgBlur

Privacy-first blur

Olly Social

Olly Social

Social AI copilot

Ceptory

Ceptory

Video intelligence

BgRemover

BgRemover

Background removal

newsletter · weekly

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

contactsupportprivacytermsdata rightssubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

← 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
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:

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:

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:

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

Then install Git:

brew install git

Verify:

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:

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:

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:

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

Create a simple file inside it:

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:

git init

You'll see:

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:

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):

git add README.md

To stage all files at once:

git add .

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

git commit -m "Add README"

You'll see output like:

[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:

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

Add it as the remote origin:

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

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

git branch -M main

Step 9: Push to GitHub

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:

# 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:

git restore --staged filename

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

git reset HEAD~1

Check where your remote is pointing:

git remote -v

Clone an existing GitHub repository to your computer:

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:

node_modules/
.env
.DS_Store
*.log
dist/

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

Related posts

Jun 27, 2026

Python Basics: How to Install Python and Write Your First Script (2026 Guide)

Install Python, run your first script, understand variables and functions, and set up a virtual environment — the complete beginner Python setup guide for 2026 with real commands and exercises.

Jun 27, 2026

What is Cursor? How to Build Your First HTML Project with AI (2026 Guide)

Cursor explained from scratch: how to install it, how the AI works, and how to build a real HTML page from a plain-English description. Your first AI-assisted project in under 30 minutes.

Jun 27, 2026

What is Docker? How to Build Your First Docker Image (Beginner Guide 2026)

Docker demystified: what an image is, what a container is, how a Dockerfile works, and how to build and run your first container in under 20 minutes.