DevOps · Git Concepts
Git and GitHub Basics Explained for Complete Beginners
Quick summary — git basics explained
Git and GitHub basics, explained for complete beginners: Git is a tool on your computer that records snapshots (commits) of a project folder (repository), lets you work on separate lines of changes (branches) and combine them (merge). GitHub is a website that stores a copy of your repository online (a remote) so you can back it up, share it and collaborate.
In this guide you will learn:
- Repositories and commits — how Git remembers history.
- Branches and merging — working on changes safely.
- Remotes and GitHub — sharing and collaborating.
- Cheat sheets — a glossary and command map.
- Tips — making the concepts stick.
SECTION 01Repositories and commits: how Git remembers
A repository is a project folder that Git watches. A commit is a saved snapshot of that folder at a moment in time, with a message explaining what changed. Together they form a history you can always go back to.
| Idea | Plain meaning | Everyday analogy | Command |
|---|---|---|---|
| Repository | A folder Git tracks | A notebook with every draft kept | git init |
| Working directory | Files as you edit them now | Your current page | git status |
| Staging area | Changes chosen for the next snapshot | Items placed in a parcel before sealing | git add |
| Commit | A saved snapshot with a message | Sealing and labelling the parcel | git commit -m |
mkdir recipes && cd recipes
git init # start tracking this folder
echo "Masala chai: water, milk, tea, ginger" > chai.txt
git status # chai.txt is untracked
git add chai.txt # stage it
git commit -m "Add chai recipe" # snapshot saved
echo "Add cardamom" >> chai.txt
git add chai.txt
git commit -m "Add cardamom to chai"
git log --oneline # list of snapshots
git show HEAD # what changed in the latest one
git diff HEAD~1 HEAD # compare the last two snapshots
SECTION 02Branches and merging: working safely
A branch is a separate line of work. You can try an idea on a branch without disturbing the main version, then merge it back if it works or simply delete it if it does not.
| Idea | Plain meaning | Everyday analogy | Command |
|---|---|---|---|
| Branch | An independent line of changes | A photocopy you scribble on | git switch -c idea |
| main | The default, stable line | The clean master copy | git switch main |
| Merge | Combine a branch into another | Copying good edits back to the master | git merge idea |
| Conflict | Same lines changed differently | Two people editing one sentence | Edit file, add, commit |
git switch -c spicy-version # new branch
echo "Add black pepper" >> chai.txt
git commit -am "Try black pepper"
git switch main # back to the stable version
git merge spicy-version # bring the change in
git branch -d spicy-version # tidy up
# What a conflict looks like inside a file
<<<<<<< HEAD
Sugar: 1 spoon
=======
Sugar: 2 spoons
>>>>>>> sweeter-version
# Fix: keep the line you want, delete the markers, then
git add chai.txt
git commit -m "Resolve sugar conflict"
SECTION 03Remotes and GitHub: sharing your work
A remote is another copy of your repository, usually on a website like GitHub. Pushing sends your commits there; pulling brings others' commits to you. GitHub adds features on top, such as pull requests, issues and project pages.
| Idea | Plain meaning | Everyday analogy | Command |
|---|---|---|---|
| Remote | A copy of the repo elsewhere | A cloud backup of your notebook | git remote add origin |
| Push | Send your commits to the remote | Uploading new pages | git push |
| Pull | Get commits from the remote | Downloading others' pages | git pull |
| Pull request | A GitHub page proposing a merge | Asking a teacher to review your edits | Opened on GitHub |
# After creating an empty repository on GitHub
git remote add origin git@github.com:yourname/recipes.git
git push -u origin main
git remote -v # shows where 'origin' points
git pull # later: get updates
git clone git@github.com:someone/project.git # copy an existing repo
# Fork = your own copy of someone else's repo, made on GitHub.
# You push to your fork, then open a pull request to the original.
git remote add upstream git@github.com:someone/project.git
git fetch upstream # see their latest changes
SECTION 04Cheat sheets for beginners
Keep these three references open while you practise. They cover the vocabulary, the commands and the everyday flow. For a related walkthrough, see Why DevOps Engineers Should Learn Kubernetes.
Glossary
repository folder tracked by Git, with full history
commit saved snapshot with a message
HEAD the commit you are currently on
branch a movable pointer to a line of commits
merge combine branches
remote another copy of the repo (e.g. on GitHub)
origin default name for your main remote
clone copy a remote repo to your computer
fork your own GitHub copy of someone else's repo
pull request a request to merge changes, with review
I want to... Command
start tracking a folder git init
see what changed git status / git diff
save a snapshot git add . && git commit -m "msg"
see history git log --oneline
try something safely git switch -c new-branch
combine work git merge branch-name
upload git push
download updates git pull
Everyday flow
1. git pull (start up to date)
2. git switch -c my-change (work on a branch)
3. edit files
4. git add + git commit (small, clear snapshots)
5. git push (share)
6. open a pull request on GitHub
7. merge after review, delete the branch
SECTION 05Tips to make the concepts stick
Concepts become natural when you see them working on your own files. A few small habits make that happen quickly. You may also find Pandas Skills for DevOps Engineer Jobs and Why Python Developers Should Learn Kubernetes useful.
- Use non-code files first — practise with recipes or notes so you focus on Git, not programming.
- Run git status often — it explains the current situation in plain words.
- Draw your branches — sketching commits as dots and branches as lines builds intuition.
- Make a conflict on purpose — resolving one calmly removes the fear.
- Read your history — git log --oneline --graph shows how your work fits together.
SECTION 06Interview Q&A — git basics explained
Q1What is the difference between Git and GitHub?
Git is version control software on your computer. GitHub is an online service that hosts Git repositories and adds collaboration tools.
Q2What is a commit?
A saved snapshot of the repository's tracked files at a point in time, with a message and a unique ID.
Q3What is the purpose of a branch?
To develop changes separately from the main line so they can be tested and reviewed before merging.
Q4What is HEAD in Git?
A reference to the commit you currently have checked out, usually the latest commit on your current branch.
Q5What is the difference between clone and fork?
Clone copies a repository to your computer. Fork creates your own copy of someone else's repository on GitHub.
SECTION 07Test yourself — git basics explained quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 08Frequently asked questions
What is Git in simple words?
A tool that keeps a history of changes to a project folder, so you can see what changed, go back and work on changes safely.
Is GitHub the same as Git?
No. GitHub is a website that hosts Git repositories. Git works on your computer even without GitHub.
Why do developers use branches?
Branches let people work on features or fixes separately without breaking the main version.
What is a pull request on GitHub?
A proposal to merge changes from one branch into another, where others can review and discuss before merging.
Can non-programmers use Git?
Yes. Writers, designers and analysts use Git to track versions of documents, configurations and data scripts.
SECTION 09Related reads
Classroom & online · Noida
Master the tools every tech team uses
Our DevOps Training Course starts with Git, GitHub and Linux before moving into CI/CD, containers and cloud, with hands-on labs at every step.
Talk to a counsellor for current fees- Git and GitHub essentials
- Linux and scripting
- CI/CD pipelines
- Weekday & weekend batches