Resources / Coding
Free to readCoding⏱ 4 min read

Git & GitHub for beginners

Save versions of your code, work with a team and show your projects to recruiters — Git and GitHub explained step by step.

Why every company asks for Git

📖 Git and version control

Definition: Version control is a system that records changes to files over time so you can recall specific versions; Git is a distributed version control system in which every developer has the full history locally.

How it works: You stage changes (git add) and record snapshots (git commit), each identified by a hash. Branches are lightweight pointers to commits, so you can develop features in parallel and merge them. Remotes (GitHub) let teams share history with push and pull.

Example: You can see who changed a line, when and why, and roll back a bad change.

🧒 In simple words

Git keeps a history of every change to your code, so you can go back in time and work with others without overwriting each other. GitHub is a website that stores Git projects online — and it doubles as your portfolio for recruiters.

Install and set up (once)

Terminal
git --version
git config --global user.name "Asha Reddy"
git config --global user.email "[email protected]"
▶ Output
git version 2.45.0

The everyday cycle

StepCommandWhat it does
1git initstart tracking a folder
2git statussee what changed
3git add .choose the changes to save
4git commit -m "Add login page"save a snapshot with a message
5git pushupload to GitHub
6git pulldownload your team's changes
💡 Tip

A good commit message says what changed in the present tense: "Fix search typo", not "changes".

Put a project on GitHub

  1. On github.com click New repository, give it a name, keep it public.
  2. In your project folder:
Terminal
git init
git add .
git commit -m "First version"
git branch -M main
git remote add origin https://github.com/your-name/project.git
git push -u origin main
▶ Output
To https://github.com/your-name/project.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.

Branches — work without breaking main

📖 Branch, merge and pull request

Definition: A branch is an independent line of development. Merging integrates the changes of one branch into another. A pull request is a GitHub feature for proposing a merge so others can review and discuss it first.

How it works: Merges can be fast-forward (just move the pointer) or create a merge commit; conflicting edits to the same lines must be resolved manually. Rebase replays commits on top of another branch for a linear history.

Example: Build a login feature on feature/login, open a PR, get it reviewed, merge into main.

🧒 In simple words

Terminal
git checkout -b new-feature    # make and switch to a branch
# …edit, add, commit…
git checkout main
git merge new-feature
▶ Output
Switched to a new branch 'new-feature'
…
Updating 3f2a1c0..9b7e4d2
Fast-forward
 login.html | 24 ++++++++++++

On teams you open a pull request on GitHub instead of merging yourself, so someone reviews your code first.

Fixing common mistakes

ProblemFix
Wrong commit messagegit commit --amend -m "Better message"
Undo changes to a filegit restore file.py
Unstage a filegit restore --staged file.py
Merge conflictopen the file, keep the right lines, delete the <<<< ==== >>>> markers, add + commit

Make your GitHub recruiter-ready

  • Pin your 3 best projects.
  • Every project has a README: what it does, a screenshot, how to run it, tech used.
  • Commit regularly — a green contribution graph shows consistency.

Interview questions

  • Git vs GitHub? Git is the tool; GitHub hosts Git projects online.
  • merge vs rebase? merge keeps both histories with a merge commit; rebase replays your commits on top for a straight line.
  • What is a pull request? A request to merge your branch after review.
  • git fetch vs git pull? fetch downloads changes; pull = fetch + merge.

Further references

🔥Join the free 30-Day Placement ChallengeOne resource and one task a day — from resume to offer.