Skip to content
Node-devs logo

Blog

Git and GitHub for Absolute Beginners: The Handful of Commands You Will Really Use Every Day

Every developer has lost a day of work to an overwritten file or "final_v3_REALLYFINAL.zip". Git ends that. This guide teaches the commands you actually use, in order: setup, commits, branches, pull requests, conflicts and undoing mistakes.

SCSam Chen Updated 4 min read
Share
Git and GitHub for Beginners - Developer Guides guide by Node-devs
Table of contents
  1. The idea
  2. Install and configure
  3. Core concepts in plain English
  4. Your first repository
  5. The daily loop
  6. Good commit messages
  7. Files you shouldn't track
  8. Connect to GitHub
  9. Branching, the safe way to work
  10. The pull request workflow
  11. Staying in sync
  12. Resolving merge conflicts
  13. Undoing mistakes
  14. Best practices
  15. GitHub features worth knowing
  16. Practice plan
  17. Engineers who work this way

Every developer has a story about overwriting a file, losing a day of work or emailing "final_v3_REALLYFINAL.zip" to a colleague. Git exists so that never happens again. It records every change, lets you try ideas on safe branches and makes teamwork possible. This teaches the Git you'll actually use daily, in the order you need it.

The idea

  • Git runs locally and tracks history. GitHub hosts repositories online.
  • The core loop: edit, stage, commit, push.
  • A branch for every feature, a pull request for review.
  • Commit small and often with clear messages.

Install and configure

Download Git from git-scm.com (Windows, macOS, Linux) and tell it who you are:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main

Create a free GitHub account and set up SSH keys or a personal access token so you can push securely. Use a strong unique password and two-factor authentication, see our password guide.

Core concepts in plain English

  • Repository (repo): a project folder with its full history.
  • Working directory: the files you see and edit.
  • Staging area: a waiting room where you choose which changes go into the next commit.
  • Commit: a saved snapshot with a message.
  • Branch: a parallel line of work so experiments don't affect the main code.
  • Remote: a copy of the repo on a server like GitHub (usually called origin).
  • Merge: combining branches.
  • Pull request (PR): a proposal to merge your branch, with review and discussion.

Your first repository

mkdir my-site
cd my-site
git init
echo "# My Site" > README.md
git status
git add README.md
git commit -m "Add README"
git log --oneline

git init created a repo, git add staged your file, git commit saved a snapshot and git log shows the history.

The daily loop

  1. Edit files.
  2. git status shows what changed.
  3. git diff shows the exact line changes.
  4. git add file.js (or git add . for everything, after checking status).
  5. git commit -m "Clear, specific message".
  6. git push to upload to GitHub.

Good commit messages

  • A short summary in the imperative: "Fix cart total rounding".
  • One logical change per commit.
  • Explain why, not only what, when it isn't obvious.

Files you shouldn't track

Make a .gitignore listing things like node_modules/, .env, build folders and OS files. Never commit secrets like API keys or passwords. If you do, rotate them immediately.

Connect to GitHub

# create an empty repo on GitHub first, then:
git remote add origin git@github.com:yourname/my-site.git
git branch -M main
git push -u origin main

To work on an existing project, clone it:

git clone https://github.com/owner/project.git
cd project

Branching, the safe way to work

git switch -c feature/contact-form    # create and move to a new branch
# ...edit, add, commit...
git push -u origin feature/contact-form
  • git branch: list branches.
  • git switch main: move to main.
  • git merge feature/contact-form: merge into the current branch.
  • git branch -d feature/contact-form: delete a merged branch.

The pull request workflow

  1. Update main: git switch main, then git pull.
  2. Branch for one task: git switch -c fix/login-bug.
  3. Commit small, logical changes.
  4. Push the branch.
  5. Open a pull request saying what changed, why and how to test.
  6. Teammates comment. You push fixes to the same branch.
  7. Merge once approved and checks pass. Delete the branch.

Tip: add automated tests and checks (continuous integration) so every PR is verified before merging.

Staying in sync

git fetch              # download changes without merging
git pull               # fetch and merge
git pull --rebase      # fetch and replay your commits on top (cleaner history)

Resolving merge conflicts

A conflict happens when two branches change the same lines. Git marks the file:

<<<<<<< HEAD
your version
=======
their version
>>>>>>> feature/other
  1. Open the file and decide what the final code should be.
  2. Remove the marker lines.
  3. Run tests.
  4. git add the file, then git commit (or git rebase --continue).

Our free diff checker is handy for comparing two versions of text or code.

Undoing mistakes

SituationCommand
Discard changes to an unstaged filegit restore file.js
Unstage a file but keep changesgit restore --staged file.js
Fix the last commit message (not pushed)git commit --amend
Safely undo a commit already pushedgit revert <commit>
Shelve work in progressgit stash and git stash pop
History of a filegit log --oneline -- file.js
Who changed a linegit blame file.js

Be careful with git reset --hard and force pushes. They can destroy work and rewrite shared history. When in doubt, make a backup branch first.

Best practices

  • Commit early and often, push at least daily.
  • Keep branches short-lived.
  • Protect main: require pull requests and passing checks.
  • Never commit secrets or large binary files.
  • Write helpful READMEs.
  • Meaningful branch names like feature/, fix/, docs/.
  • Review your own diff before opening a PR.

GitHub features worth knowing

  • Issues and projects for tracking work.
  • Actions for automated tests and deployments.
  • Pages for free static hosting.
  • Dependabot and security alerts for vulnerable dependencies.
  • Forks and open source: fork, change, open a PR. A great way to build a portfolio. See our web developer roadmap.

Practice plan

  1. Create a repo and make five commits with good messages.
  2. Branch, change something, push it and merge through a pull request on your own repo.
  3. Create a deliberate conflict and resolve it.
  4. Fork a beginner-friendly open-source project and fix a typo.

Engineers who work this way

At Node-devs every project uses Git, pull requests, code review and automated checks, and clients receive the full repository. Learn more about our development process or talk to us about your project.

Frequently asked questions

What is the difference between Git and GitHub?+

Git is version control software that runs on your computer and tracks changes to files. GitHub is a website that hosts Git repositories online so you can back them up, share them and collaborate through pull requests.

Do I need GitHub to use Git?+

No. Git works entirely on your own machine. GitHub (or GitLab, Bitbucket) adds remote storage and collaboration features.

What is a commit?+

A commit is a saved snapshot of your project at a point in time, with a message describing what changed. You can return to any commit later.

What is a pull request?+

A pull request asks the project owner to review and merge your branch's changes into another branch such as main. It is the standard way teams review code.

How do I undo a mistake in Git?+

It depends on the mistake. For uncommitted changes you can restore files; for a bad commit you can revert it (safe for shared history) or reset locally. Learn git status, git log, git restore and git revert first.

SC

Written by

Sam Chen

Node-devs Team

Related Articles

Get practical tech insights, monthly

One email a month with our best guides on software, AI and growth. No spam - unsubscribe any time.

Contact Our Team

We pride ourselves staying at the front of innovation, constantly pushing boundaries - shaping the Digital World Together and redefining what's possible.

To More Inquiry

+8801867748073

To Send Mail

info@node-devs.com

Your Success Starts Here!

Protected by reCAPTCHA & honeypot spam filtering.

Git and GitHub for Absolute Beginners: Daily Commands