Learn Programming, Tech & Coding · Free Online Tools

IT Question Answer
Back to Git

Git Basics: Commands Every Developer Should Know

Git2,200 viewsBy Muhammad Fareed
gitversion-controlcommandsbasics

Git Basics: Essential Commands

Essential Git commands that every developer should master for version control.

Initial Setup

# Configure Git
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

Basic Commands

Initialize Repository

git init

Clone Repository

git clone https://github.com/user/repo.git

Check Status

git status

Add Files

git add .
git add filename.txt

Commit

git commit -m "Your commit message"

Push

git push origin main

Branching

# Create branch
git branch feature-branch

# Switch branch
git checkout feature-branch

# Create and switch
git checkout -b feature-branch

# Merge branch
git merge feature-branch

Useful Commands

  • git log - View commit history
  • git diff - See changes
  • git pull - Fetch and merge
  • git stash - Temporarily save changes