GIT BASICS: UNDERSTAND VERSIN CONTROL, TRACK CHANGES, PUSH AND PULL CODES FOR BEGINNERS

Published: (January 17, 2026 at 04:30 PM EST)
3 min read
Source: Dev.to

Source: Dev.to

Git Bash

Git simplifies version control by letting you save snapshots of your code, collaborate safely, and revert mistakes easily.

What is version control?

Version control is a system that helps you:

  • Track changes made to files over time.
  • Go back to previous versions if something breaks.
  • Collaborate with others without conflicts.

What are Git and GitHub?

  • Git – a tool installed on your computer that tracks changes in your project.
  • GitHub – an online platform where you store Git repositories and collaborate with others.

Key terms to know

  • Repository – a folder where Git tracks your project’s history.
  • Working directory – where you edit your files.
  • Staging area – where you prepare files before you permanently save them.
  • Commit – a snapshot of your project at a specific point in time.

Setting Up Git

First, confirm the version of the installed Git Bash:

git --version

Git version output

Configure your name and email:

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

Generate an SSH key

An SSH key is a secure access credential.

ssh-keygen -t ed25519 -C "you@example.com"
  • -t specifies the key type (ed25519 is a secure encryption method).
  • -C adds a comment (usually your email).

This generates a private key (id_ed25519) and a public key (id_ed25519.pub). The public key will be linked to GitHub.

Start the SSH agent

eval "$(ssh-agent -s)"

Add the SSH key to the agent

ssh-add ~/.ssh/id_ed25519

Copy your public SSH key

cat ~/.ssh/id_ed25519.pub

Add the SSH key to GitHub

  1. Go to GitHub → Settings → SSH and GPG keys.
  2. Click New SSH key, give it a title, paste the copied key, and click Add SSH key.

Tracking your changes

Git tracks changes in three stages: working directory, staging area, and commit history.

Working directory

The working directory holds all project files as they appear on your computer. You edit files here.

Steps to create a repository

mkdir my-first-repo      # Create a new folder
cd my-first-repo          # Enter the folder
git init                  # Initialise Git (turns the folder into a repository)

Git init screenshot

Create a file:

touch README.md

Create README screenshot

Staging

When you modify a file, Git knows about the change but does not yet include it in the next snapshot. Stage the files you want to commit:

git add README.md

Commit

After staging, create a commit with a descriptive message:

git commit -m "Add README.md file"

Commit screenshot

Add the GitHub repository as a remote (replace with your actual URL):

git remote add origin git@github.com:username/repository-name.git
git remote -v   # Verify the remote

How to Push Code to GitHub

git push -u origin main
  • origin – the name of the remote repository.
  • main – the branch you are pushing to.

How to Pull Code from GitHub

git pull origin main

Use this when:

  • Working on multiple branches.
  • Collaborating with a team.
  • Updating your local project with remote changes.

Git workflow

  1. Edit files.
  2. git add → stage changes.
  3. git commit → save changes.
  4. git push → upload to GitHub.
  5. git pull → download updates.

Conclusion

Git may seem daunting at first, but it is an essential tool for developers. By mastering add, commit, push, and pull, you’ve covered the core workflow and can now apply Git daily.

Back to Blog

Related posts

Read more »

Introduction to Git and Github

Why version control is important - Every change is recorded - You can go back to older versions of your code - You can see who made a change and when - Multipl...