Git & GitHub for Beginners: Create Your First Repo, Commit and Push | KodeHunter
DEVELOPER BASICS ยท BEGINNER'S GUIDE

Git & GitHub for Beginners: Your First Repo, Commit and Push

Every developer uses Git and GitHub every day. Learn how they work, the words you will hear, and the exact commands to get your first project online.

โฑ 10 min read๐ŸŽฏ For: complete beginners๐Ÿ—“ Updated: Nov 2026
๐Ÿ’ปYour computerGit โ˜๏ธGitHubonline home pushpull Save, share and collaborate on code

TL;DR

  • Git is a tool on your computer that tracks changes to your code. GitHub is a website that stores Git projects online.
  • The daily routine is four commands: git add โ†’ git commit โ†’ git push, and git pull to get others' changes.
  • Work on a branch, then open a pull request so teammates can review before merging.
  • You can have your first repo online in about 15 minutes. Follow the steps below.

Git vs GitHub: what's the difference?

People mix these up all the time. Think of writing a book:

๐Ÿ•ฐ๏ธ

Git = the history tool

Software installed on your computer. It saves a snapshot every time you ask it to, so you can go back to any earlier version. It works fully offline.

โ˜๏ธ

GitHub = the online home

A website that stores your Git projects in the cloud. It adds sharing, teamwork, code review and a public profile that shows your work.

You can use Git without GitHub. But almost everyone pairs them, because GitHub is where the code is backed up and where teams collaborate. (GitLab and Bitbucket are similar websites. Everything here works the same on them.)

The four places your code lives

1. Working folderfiles you edit 2. Staging areaready to save 3. Local reposaved history 4. GitHubonline copy git addgit commitgit push โ† git pull / git clone brings changes back from GitHub
Understand these four places and Git stops being confusing.

Words you will hear

TermMeaning in plain English
Repository (repo)A project folder whose history Git tracks.
CommitA saved snapshot of your changes, with a short message describing it.
BranchA separate line of work. Lets you try things without touching the main code.
Remote / originThe online copy of your repo (on GitHub). origin is its default nickname.
CloneDownload a copy of a GitHub repo to your computer.
ForkYour own copy of someone else's repo on GitHub, used to propose changes to it.
Push / PullPush uploads your commits to GitHub. Pull downloads others' commits to you.
Pull request (PR)A request to merge your branch into another, so teammates can review first.
MergeCombining the changes from one branch into another.
IssueA task, bug or idea tracked on GitHub.

Public vs private repositories

A public repo can be seen by anyone, which is great for a portfolio. A private repo is visible only to you and people you invite. Companies mostly use private repos for their work. Choose public for practice projects, and never put passwords or keys in either.

Set up in 5 steps

1

Create a GitHub account

Go to github.com and sign up for a free account. Pick a professional username, since it appears in your profile link and is what people see.

2

Install Git

Download Git from git-scm.com (Windows, macOS and Linux). On macOS, running the command below may offer to install it for you. Check that it worked:

$ git --version
# git version 2.xx.x

If you see a version number, you're ready. On Windows, the installer also gives you Git Bash, a terminal you can use for these commands.

3

Tell Git who you are

Git stamps your name and email on every commit. Use the same email as your GitHub account:

$ git config --global user.name "Your Name"
$ git config --global user.email "you@example.com"
4

Connect your computer to GitHub

GitHub no longer accepts your account password for Git commands. Pick one of these:

  • GitHub CLI (easiest): install it from cli.github.com, run gh auth login and follow the prompts in your browser.
  • SSH key: generate one with ssh-keygen -t ed25519 -C "you@example.com" and add the public key under GitHub โ†’ Settings โ†’ SSH keys.
  • Personal access token: create one in GitHub settings and paste it when Git asks for a password over HTTPS.
Keep secrets secret: never share your token or private key, and never commit them to a repo.
5

Pick a place for your projects

Create a folder for your code so you always know where to find it:

$ mkdir projects
$ cd projects

Your first repo: create, commit, push

We will create a repo on GitHub, bring it to your computer, change a file and send it back.

A. Create the repo on GitHub

  1. Click the + icon (top right) โ†’ New repository.
  2. Name it hello-github.
  3. Choose Public, tick Add a README file, and click Create repository.

B. Clone it to your computer

Click the green Code button, copy the URL, then run:

$ git clone https://github.com/YOUR-USERNAME/hello-github.git
$ cd hello-github

C. Make a change

$ echo "My first change" >> notes.txt
$ git status
# Untracked files: notes.txt

git status is your best friend. It tells you what changed and what to do next. Use it often.

D. Stage, commit and push

$ git add notes.txt
$ git commit -m "Add notes file"
$ git push

Refresh your repo page on GitHub. Your file and commit message are there. You just pushed your first commit! ๐ŸŽ‰

E. Getting changes back: pull

If a teammate (or you, from another computer) pushes changes, bring them down with:

$ git pull
Habit to build: run git pull before you start work each day, so you begin from the latest code.

Starting from a project you already have?

If your code is already on your computer, turn the folder into a repo and connect it to a new, empty GitHub repo:

$ git init
$ git add .
$ git commit -m "First commit"
$ git branch -M main
$ git remote add origin https://github.com/YOUR-USERNAME/my-project.git
$ git push -u origin main

Try it: see where your files go

๐Ÿงช The 4 zones, interactive

Click the buttons in order and watch a file move from your folder to GitHub.

WORKING FOLDER
STAGING AREA
LOCAL REPO
GITHUB
$ Ready. Start by editing a file.

Branches and pull requests: how teams work

In a team, nobody edits the main code directly. Instead, everyone works on their own branch, then asks for their work to be reviewed and merged through a pull request.

mainyour branch: feature-loginmerged via pull request
Your work happens safely on a branch. The pull request is the door back to main.

The full routine looks like this:

$ git pull                         # start from the latest main
$ git switch -c add-contact-page   # create and move to a new branch

# ...edit files...

$ git add .
$ git commit -m "Add contact page"
$ git push -u origin add-contact-page

Then on GitHub:

  1. You will see a banner "Compare & pull request". Click it.
  2. Write a short title and a description of what you changed and why.
  3. A teammate reviews it, may leave comments, and approves.
  4. Click Merge pull request. Your work is now part of main.

Finally, tidy up locally:

$ git switch main
$ git pull

Contributing to someone else's project

You usually can't push directly to a project you don't own. The open-source way is: fork the repo (your own copy on GitHub) โ†’ clone your fork โ†’ make a branch โ†’ push โ†’ open a pull request to the original project.

Command cheat sheet

CommandWhat it does
git clone <url>Download a repo from GitHub
git statusSee what changed
git add <file> / git add .Stage one file / stage everything
git commit -m "message"Save a snapshot with a message
git pushUpload commits to GitHub
git pullDownload and apply others' changes
git log --onelineSee the commit history
git diffSee exactly what you changed
git switch -c <name>Create and move to a new branch
git switch <name>Move to an existing branch
git branchList branches

Common problems (and easy fixes)

"Push rejected" or "failed to push"

Someone pushed before you. Run git pull first, then git push again.

Merge conflict

Two people changed the same lines. Git can't choose, so it marks both versions in the file. Open the file, keep the correct lines, delete the markers (<<<<<<<, =======, >>>>>>>), then git add and git commit. It looks scary the first time and becomes routine quickly.

Committed something you shouldn't have

Add private files such as .env or node_modules/ to a file named .gitignore so Git skips them. If you ever commit a password or key, treat it as leaked and change it right away. Deleting the file in a later commit does not remove it from history.

Writing good commit messages

  • Short and specific: Fix login button alignment, not changes.
  • Start with a verb: add, fix, update, remove.
  • One logical change per commit.
Make it a habit: commit small and often, and write a README for each project. Your GitHub profile becomes a record of everything you build.

FAQ

What is the difference between Git and GitHub?

Git is a version control tool that runs on your computer. GitHub is a website that hosts Git repositories online so you can back them up, share them and collaborate.

What is a repository?

A repository, or repo, is a project folder whose history of changes is tracked by Git.

Clone vs fork: what's the difference?

Cloning copies a repo from GitHub to your computer. Forking creates your own copy of someone else's repo on GitHub, usually so you can propose changes.

What is a pull request?

A request to merge your changes from one branch into another, giving teammates a chance to review them first.

Is GitHub free?

Yes. The free plan includes unlimited public and private repositories for individuals. Paid plans add extra features.

Do I need to use the command line?

No. Tools such as GitHub Desktop and the Git features in VS Code let you do the same things with buttons. Learning the commands once helps you understand what those buttons do.

Talk to a mentor

Leave your details and we will follow up with writing and sessions that match what you are working on.