A Beginner's Guide on Git & GitHub for Version Control
Source: Dev.to

Introduction
Version control helps developers track code changes and collaborate more effectively. Git and GitHub are tools that make this possible. Git is a version‑control system, while GitHub is an online platform that stores projects in the cloud. In this article you’ll learn the basic Git commands used for version control.
Getting Started
- Download and install Git from the official website.
- After installation, configure Git with your name and email address:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
- Sign up for a GitHub account at the GitHub sign‑up page and set up your profile.
Git Commands for Version Control
git init– Initializes a directory so Git can start tracking changes.git clone– Makes a copy of a GitHub repository on the local machine.git add– Adds files to the staging area.git commit– Saves the files that were added to the staging area.git push– Sends recent commits from your local repository to GitHub.git pull– Fetches and updates your local repository with changes from GitHub.
Initializing a Git Repository
We’ll use a simple example project called my‑first‑repo to demonstrate how the Git commands work.
-
Create a project folder and navigate into it.
-
Initialize the repository:
git init
-
Create a file in the project folder and check its status:
git status
-
Add files to the staging area and commit them:
git add . git commit -m "Initial commit"
-
Push to GitHub
- Create a new repository on GitHub.
- Copy the repository URL.
- Connect your local project and push:
git remote add origin git branch -M main git push -u origin main

Your project is now available on GitHub.
Git Collaboration and Conflict Resolution
You can collaborate effectively by creating branches. Branching allows each collaborator to work on the same project without interfering with each other.
git branch– Create a new branch.git checkout– Switch to the specified branch.git merge– Merge the branch into the current branch (e.g.,main).
Conclusion
Git and GitHub are essential tools for every developer. With just a few basic commands—git init, git add, git commit, git push, and git pull—you can track your work, collaborate with others, and safely manage your code. Practicing these commands will build your confidence in version control.