PROGRAM ZERO 18-month live AI, LLM & full-stack programme · ₹5,999 for all 18 months · Starts 9 January 2027
Explore Program Zero →
Careers Ninza — business and startup leadership training
JOIN ZERO NINZA KIDS
JOIN ZERO NINZA KIDS
Careers Ninza
SOFTWARE 10 min read · Updated 24 September 2026

Git and GitHub for absolute beginners

What version control is, how Git differs from GitHub, the handful of commands you will use every day, your first repository step by step, and how to undo the common mistakes.

CN
Careers Ninza engineering faculty
Careers Ninza · Kolkata, India

Git is a version control tool that records every change to your code, so you can go back, compare versions and work with others without overwriting each other. GitHub is a website that hosts Git repositories online. Beginners need only a handful of commands: init, add, commit, push, pull and branch, plus the habit of committing often.

Almost every software team uses Git, and your GitHub profile is often the first thing a recruiter or client looks at. This guide starts from zero and gets you to your first repository online, then covers branches, pull requests and how to undo common mistakes.

What is version control, and why do you need it?

If you have ever had files called project_final.docx, project_final_v2.docx and project_final_REALLY_final.docx, you have done version control by hand. It is messy, and it breaks down completely when several people edit the same files.

Git solves this properly. Each time you save a meaningful change, you make a commit: a snapshot of your project with a message explaining what changed. You can see the full history, compare any two versions, go back to an earlier one, and work on experiments without risking the version that works.

What is the difference between Git and GitHub?

GitGitHub
What it isA version control toolA website that hosts Git repositories
Where it runsOn your own computerOnline
Needs internet?No, works offlineYes, to push and pull
Used forTracking history and branches locallyBackup, sharing, collaboration, portfolio

You can use Git without GitHub, and there are other hosting services. But Git plus GitHub is the most common combination, especially for beginners building a public portfolio.

What are the key ideas?

TermMeaning
Repository (repo)A project folder whose history Git is tracking
CommitA saved snapshot of changes, with a message
Staging areaWhere you choose which changes go into the next commit
BranchA separate line of work, so you can experiment safely
RemoteA copy of the repo somewhere else, usually on GitHub
Push / pullSend your commits to the remote / bring others’ commits to you
CloneDownload a full copy of a repo, with its history
Pull requestA request to merge one branch into another, with review

How do you create your first repository?

Install Git from the official site, then open a terminal. First, tell Git who you are; this is recorded in every commit:

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

Create a project folder, turn it into a repository, and check its status:

mkdir my-first-repo
cd my-first-repo
git init
git status

Create a file, for example a README.md describing the project. Then stage it and commit it:

git add README.md
git commit -m "Add README with project description"

Now put it on GitHub. Create a new, empty repository on GitHub, then connect your local repo to it and push. GitHub shows these exact commands when you create a repository:

git branch -M main
git remote add origin https://github.com/your-username/my-first-repo.git
git push -u origin main

Refresh the GitHub page and your file is there. From now on, the daily loop is simple: edit, git add, git commit, git push.

What are branches and pull requests?

A branch lets you work on something new without touching the working version. Create one, switch to it, make commits, and push it:

git switch -c add-contact-page
# edit files, then:
git add .
git commit -m "Add contact page with form"
git push -u origin add-contact-page

On GitHub, you then open a pull request asking to merge add-contact-page into main. Teammates review the changes, comment and approve, and then it is merged. This is how nearly every professional team works, so practise it even on solo projects.

To get changes others have pushed, run git pull before you start work each day.

What should you never commit?

Never commit passwords, API keys, or files such as .env that contain secrets. Once pushed to a public repository, assume a secret has been seen, even if you delete it later; Git keeps history. If it happens, revoke and replace the key immediately.

Create a .gitignore file listing what Git should ignore:

.env
node_modules/
__pycache__/
*.log

Leaked keys are one of the most common and expensive beginner mistakes. Security habits start here; our guide to the DPDP Act for developers explains why secrets management and access control matter legally, not just technically.

What is a merge conflict, and how do you fix one?

A merge conflict happens when two branches change the same lines of the same file, and Git cannot decide which version to keep. It is normal, not a disaster. Git marks the conflict inside the file like this:

<<<<<<< HEAD
<h1>Welcome to our store</h1>
=======
<h1>Welcome to Sharma General Store</h1>
>>>>>>> add-store-name

The part above the ======= line is your current branch; the part below is the incoming branch. Edit the file so it contains the version you actually want, delete the three marker lines, then stage and commit the result. Most code editors, including VS Code, highlight conflicts and offer buttons to accept one side or both. Pulling often and keeping branches short-lived makes conflicts smaller and rarer.

How do you write a good commit message?

Write what the commit does, in the imperative, as if completing “This commit will…”. Good: Fix login error when email has capital letters. Unhelpful: changes, update, asdf. Small, focused commits with clear messages make your history readable, and reviewers notice.

What are the common mistakes, and how do you undo them?

SituationWhat to run
Not sure what state you are ingit status
See the historygit log --oneline
Discard changes to a file you have not stagedgit restore filename
Unstage a file you added by mistakegit restore --staged filename
Fix the message of your last commit (before pushing)git commit --amend
Undo a commit that is already pushedgit revert <commit-id>

The golden rule: git status tells you almost everything, so run it constantly. And avoid rewriting history that others have already pulled; use git revert, which adds a new commit that undoes an old one, instead.

How does GitHub work as a portfolio?

For beginners and career switchers, GitHub is a living CV. A few well-documented projects, each with a clear README explaining what it does, how to run it and what you learned, say more than a certificate. Regular commits show consistency. Our realistic plan for switching to tech explains how to build that portfolio over time.

Two excellent free references: the Pro Git book on the official Git website, and GitHub’s getting-started documentation.

Git is part of the very first phase of Program Zero: Phase 0 covers Git and GitHub alongside Linux, the command line and how the internet works, so every project after that lives in a repository. For how Git fits into the wider skill set, see Program Zero’s full-stack developer roadmap for India.

Want to learn this live, with mentors?

Program Zero starts with foundations, Linux, the command line, Git and GitHub, then builds up to full-stack development and AI over 18 months of live classes. ₹5,999 for all 18 months; the batch starts 9 January 2027.

Frequently asked questions

What is the difference between Git and GitHub?+

Git is a version control tool that runs on your computer and records the history of your project. GitHub is a website that hosts Git repositories online, adding backup, sharing, pull requests and collaboration. You can use Git without GitHub, but most developers use both, and a GitHub profile often serves as a public portfolio.

Which Git commands should a beginner learn first?+

Start with git init, git status, git add, git commit, git push and git pull. Then learn git log to see history, git switch -c to create branches, and git restore to discard or unstage changes. Those few commands cover most day-to-day work, and git status tells you what state you are in at any time.

What should I do if I accidentally push a password or API key to GitHub?+

Revoke and replace the key or password immediately, because anything pushed to a public repository should be treated as exposed, even after deletion. Then remove it from the code, add the file to .gitignore, and store secrets in environment variables or a secrets manager rather than in the repository.

Is Git hard to learn?+

The basics are not. Most beginners are comfortable with the daily add, commit, push and pull loop within a week or two of regular use. Branches, merge conflicts and undoing mistakes take longer, but they become familiar through practice on real projects, especially if you use pull requests even when working alone.

Related reading

We teach this, live

Every article here comes from something we teach. Sit in on a free masterclass and judge the mentors yourself.