A beginners guide to Git and Github

Published: (February 1, 2026 at 10:46 AM EST)
4 min read
Source: Dev.to

Source: Dev.to

Definition of Git and GitHub

These two terms may seem familiar to someone new, but they are not the same.

  • Git – a free, open‑source tool used for tracking changes in files and managing version history locally.
  • GitHub – a web‑based platform that provides repository hosting, team collaboration, and project‑management features.

In short: you do not need GitHub to use Git, but you need Git to work with GitHub.

Connecting Git to a GitHub Account

  1. Install Git – download it from the official Git website.

  2. Create a GitHub account – if you don’t have one already.

  3. Configure Git with your credentials – open a terminal (or Command Prompt) and run:

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

    These values will be attached to every commit you make.

    Git configuration screenshot

  4. Create a repository on GitHub – log in to GitHub.com, click the + sign at the top‑right, and select New repository.

  5. Name the repository and click Create repository.

  6. Authentication – when you push to a GitHub repository from Git, you must authenticate either via HTTPS or SSH:

    • HTTPS (recommended for most users) – you can cache your credentials with a credential helper.
    • SSH – generate an SSH key pair on each computer you use and add the public key to your GitHub account.

You now have Git and GitHub set up, allowing you to store projects as backups and share your work globally.

What Is Git and Why Is Version Control Important?

  • Git is a free, open‑source distributed version‑control system.
  • A Version‑Control System (VCS) tracks and records changes to files (or groups of files), letting you recall any previous iteration when needed.

Version control enables people in different locations to collaborate on the same project. With Git, each developer can work locally, commit changes, and then synchronize those changes to a shared repository so others can see the latest version.

Importance of Version Control

  1. Reversion – Detailed tracking makes it easy to roll back to an earlier version if necessary.
  2. Attribution – Every change is linked to the team member who made it.
  3. Branching – Teams can work on separate branches (features, bug‑fixes, experiments) and later merge them.
  4. Concurrency – Multiple developers can work simultaneously while Git helps prevent conflicts.
  5. Organization & Communication – Commit messages explain what changed and why, improving project clarity.

Git Push

The git push command transfers commits made on a local branch to a remote repository (e.g., GitHub).

git push

Example Workflow: Creating a New Repository and Pushing Your First Commit

  1. Create a new repository on GitHub

    • Click the + sign → New repository.
    • Fill in the repository name, description, and set it to Public (free).

    Create repository screenshot

  2. Open Git Bash (or your preferred terminal).

  3. Navigate to your project folder

    cd /path/to/your/project
    pwd   # prints the current directory (optional)
  4. Initialize the Git repository

    git init

    git init screenshot

  5. Add files to the repository

    git add .
    git status   # shows which files are staged
  6. Commit the staged files

    git commit -m "Add initial project files"

    Commit messages should be concise (≈50 characters) and written in the imperative mood, describing what changed and why.

    git commit screenshot

  7. Add the remote (GitHub) repository

    git remote add origin https://github.com/your‑username/your‑repo.git
  8. Push the commit to GitHub

    git push -u origin main   # or whatever branch you are using

Your code is now stored on GitHub and ready to be shared or collaborated on.

Copy Your Remote Repository’s URL and Push

The HTTPS URL is copied from the GitHub page that hosts the remote repository.

git push -u origin main
  • origin – default name of the remote repository.
  • -u (or --set-upstream) – sets the upstream (tracking) branch.
  • main – the branch you are pushing.

You will be prompted to enter your GitHub username and password (or a personal access token).

Push to GitHub

How to Pull Code from GitHub

  • GitHub Desktop provides a graphical interface for these operations.
  1. Open GitHub Desktop.
  2. Click the File menu → Clone repository… (first time) or select an existing repository from the list (to get updates).
  3. If cloning:
    • Choose the repository from your GitHub account or paste the URL.
    • Select a local path.
    • Click Clone.
  4. If updating an existing repo:
    • Click Fetch origin or Pull origin in the top bar to sync your local branch with the remote.

Tracking File Changes Using Git

Tracking file changes with Git enables effective version control by recording updates and maintaining a clear history of modifications.

  • Keeps a complete version history of files.
  • Helps review and manage changes over time.

Viewing Commit History of a File

  1. Check the current status of the repository (good practice before viewing history).

    git status

    This displays untracked, modified, or staged files.

  2. View the change history of a specific file.

    git log -- <file>

    Git log output

  3. View the changes made in a particular commit.

    git show <commit-hash>

    Git show output

Back to Blog

Related posts

Read more »

Why GIT Exists: The Pendrive Problem

If you are a developer, you’ve probably heard of Git and GitHub. But why was Git created? What problems existed before Git, and how was code managed before mode...