KaryvioKaryvio
JobsBlogDeveloper ResourcesAI & Machine LearningCloud & DevOps
Sign in
Home/Developer Resources/Git Commands Every Developer Should Know: A Practical Guide for Beginners
Developer Resources

Git Commands Every Developer Should Know: A Practical Guide for Beginners

Git is one of the most important tools in modern software development. Learn the essential Git commands for managing code, creating branches, working with GitHub, and collaborating on projects.

S

Sibun

Sep 11, 2026 · 16 min read

Git Commands Every Developer Should Know: A Practical Guide for Beginners
BeginnerGitGithubCommand Line

Tools used: Git, Github, Terminal, Command Line

Prerequisites: Basic command-line knowledge and a Git installation. No professional software development experience is required.

Git Commands Every Developer Should Know: A Practical Guide for Beginners

Git is one of the most important tools in modern software development.

Whether you're building a personal project, working with a development team, or contributing to an open-source project, Git helps you track changes, manage your code, and collaborate safely.

If you're new to Git, the number of commands can feel overwhelming.

You don't need to memorize hundreds of commands.

You need to understand the core Git workflow and become comfortable with the commands you will use regularly.

Don't try to memorize Git commands without understanding what they do. Learn the workflow first, then learn the commands that support it.


The Basic Git Workflow

The most common Git workflow looks like this:

Diagram / Architecture

The most common commands involved are:

bash
git status
git add
git commit
git push

These four commands are used constantly in everyday development.


1. Check Whether Git Is Installed

Before using Git, check whether it is installed on your computer.

bash
git --version

You should see a version similar to:

text
git version 2.x.x

The exact version depends on your installation.

If Git is not installed, install it using the official Git distribution for your operating system.


2. Configure Your Git Identity

Git uses your name and email address to associate commits with an author.

Set your name:

bash
git config --global user.name "Your Name"

Set your email:

bash
git config --global user.email "you@example.com"

Check your configuration:

bash
git config --global --list

Use an email address that you are comfortable associating with your development commits.

If you're using GitHub, you can also configure Git to use an appropriate GitHub-associated email address.


3. Create a New Git Repository

If you already have a project on your computer and want Git to start tracking it, move into the project directory.

bash
cd my-project

Then initialize Git:

bash
git init

Git creates a hidden .git directory containing the repository's version-control information.

Your project now has a local Git repository.

text
my-project/
├── src/
├── public/
├── package.json
└── .git/

Do not manually modify files inside the .git directory unless you understand exactly what you are doing. Git manages this directory for you.


4. Check Repository Status

One of the most useful Git commands is:

bash
git status

It tells you things such as:

  • Which files have changed
  • Which files are staged
  • Which files are untracked
  • Which branch you're currently using

For example:

text
On branch main

Changes not staged for commit:
  modified: src/app.js

Untracked files:
  notes.md

When you're unsure about the current state of your repository, start with:

bash
git status

If you only remember one Git command at first, remember git status.


5. Add Files to the Staging Area

After changing your code, Git knows that files have changed, but those changes are not automatically included in your next commit.

Use:

bash
git add filename

For example:

bash
git add app.js

To stage multiple files:

bash
git add app.js styles.css

To stage all current changes:

bash
git add .

The staging area lets you decide which changes should be included in your next commit.


6. Understand the Staging Area

A useful way to understand Git is:

Diagram / Architecture

Suppose you changed three files:

text
app.js
styles.css
README.md

You might stage only the code changes:

bash
git add app.js styles.css

Then create a commit.

The README changes remain outside that commit.

This gives you more control over your project's history.


7. Create a Commit

Once your changes are staged, create a commit:

bash
git commit -m "Add user authentication"

A commit is a saved point in your project's history.

Good commit messages describe what changed.

Better Examples

bash
git commit -m "Add responsive navigation"
bash
git commit -m "Fix login form validation"
bash
git commit -m "Add job search filters"

Avoid vague messages such as:

bash
git commit -m "changes"

or:

bash
git commit -m "update"

A useful commit message makes your project history easier to understand.


8. View Commit History

To view recent commits:

bash
git log

For a shorter version:

bash
git log --oneline

You may see something like:

text
a83f21d Add responsive navigation
71bc921 Fix login validation
4a91e20 Create project structure

The short commit ID can be useful when working with Git history.


9. Connect Your Local Repository to GitHub

Git and GitHub are related, but they are not the same thing.

Git is the version-control system.

GitHub is a platform that hosts Git repositories and provides collaboration features.

After creating a repository on GitHub, connect your local project to it.

For example:

bash
git remote add origin https://github.com/username/my-project.git

Check the remote:

bash
git remote -v

You should see your GitHub repository listed.


10. Push Your Code to GitHub

After committing your changes, push them to the remote repository.

bash
git push origin main

This sends your local commits to GitHub.

The general workflow becomes:

Diagram / Architecture

This is one of the most important workflows to understand as a developer.


11. Clone an Existing Repository

If a project already exists on GitHub and you want a local copy, use:

bash
git clone https://github.com/username/project.git

Then move into the project:

bash
cd project

You now have a local copy of the repository.

A common workflow when joining a project is:

Diagram / Architecture

12. Create a Branch

Branches allow you to work on changes without modifying the main development line directly.

Create a branch:

bash
git branch feature/login

Switch to it:

bash
git switch feature/login

Or create and switch in one command:

bash
git switch -c feature/login

Now your work is happening on the new branch.


13. Check Your Current Branch

Use:

bash
git branch

The current branch is usually marked with an asterisk.

For example:

text
* feature/login
  main

You can also use:

bash
git status

to see your current branch.


14. Switch Between Branches

To switch to another branch:

bash
git switch main

To switch back:

bash
git switch feature/login

Before switching branches, make sure you understand what will happen to your current uncommitted changes.


15. Merge a Branch

Suppose you've finished working on a feature branch.

First switch to the branch that should receive the changes:

bash
git switch main

Then merge:

bash
git merge feature/login

Git attempts to combine the changes from the feature branch into main.

A simplified workflow is:

Diagram / Architecture

In team environments, merging is often handled through Pull Requests.


16. Pull Changes From GitHub

Before starting work, you may need the latest changes from the remote repository.

Use:

bash
git pull

A common workflow is:

bash
git switch main
git pull

Then create your feature branch:

bash
git switch -c feature/new-feature

This helps you start from an updated version of the project.


17. Fetch Remote Changes

Another useful command is:

bash
git fetch

Fetching retrieves information about remote changes without automatically merging those changes into your current branch.

The difference is:

text
git fetch
→ Download information about remote changes

git pull
→ Fetch and integrate remote changes

18. See What Changed

To see unstaged changes:

bash
git diff

To see staged changes:

bash
git diff --staged

These commands are useful before committing.

A simple workflow is:

Diagram / Architecture

This gives you an opportunity to catch accidental changes before they become part of your project history.


19. Temporarily Save Work With Git Stash

Sometimes you have unfinished changes but need to switch branches.

You can temporarily store them:

bash
git stash

Your working directory becomes clean.

Later, restore the changes:

bash
git stash pop

A typical situation is:

Diagram / Architecture

Stashing is useful for temporary work, but don't use it as a replacement for meaningful commits.


20. Remove a File From Staging

Suppose you accidentally staged a file:

bash
git add secrets.txt

You can remove it from the staging area with:

bash
git restore --staged secrets.txt

The file remains in your working directory, but it is no longer staged for the next commit.


21. Discard Local Changes Carefully

If you want to restore a file to its last committed version:

bash
git restore filename

For example:

bash
git restore app.js

This can permanently discard uncommitted changes in that file.

Be careful with commands that discard changes. If the work has not been committed or backed up, it may be difficult or impossible to recover.


22. Rename a File With Git

You can rename a tracked file using:

bash
git mv old-name.js new-name.js

Then commit the change:

bash
git commit -m "Rename user service file"

23. Delete a Tracked File

To remove a tracked file:

bash
git rm old-file.js

Then commit:

bash
git commit -m "Remove unused file"

24. Use a .gitignore File

Not every file should be committed to Git.

Common examples include:

  • Dependency folders
  • Build output
  • Local environment files
  • Temporary files
  • Operating-system files
  • Editor-specific files

A typical .gitignore might include:

gitignore
node_modules/
dist/
build/
.env
.DS_Store

The exact contents depend on your project.

Never commit passwords, private API keys, database credentials, access tokens, or other sensitive secrets to a public repository.


25. Understand Pull Requests

A Pull Request, commonly called a PR, is a way to propose changes to a repository.

A typical team workflow looks like:

Diagram / Architecture

A good Pull Request should explain:

  • What changed
  • Why it changed
  • How it was implemented
  • How it was tested
  • Anything reviewers should know

Keep Pull Requests focused when possible.


26. Resolve Merge Conflicts

Sometimes Git cannot automatically combine changes.

You may see a merge conflict like:

text
<<<<<<< HEAD
const title = "Developer";
=======
const title = "Frontend Developer";
>>>>>>> feature/profile

The conflict markers show the competing changes.

You need to decide which version should remain.

After resolving the file:

bash
git add filename

Then complete the merge or commit process as required.

Don't blindly choose one side of a conflict. Understand what both changes were trying to accomplish before resolving it.


27. View Remote Repositories

To see configured remote repositories:

bash
git remote -v

You might see:

text
origin  https://github.com/username/project.git (fetch)
origin  https://github.com/username/project.git (push)

The name origin is a common default name for the main remote repository.


28. Create a New Branch From the Latest Main Branch

Before starting a new feature, a common workflow is:

bash
git switch main
git pull
git switch -c feature/dashboard

Now your new branch starts from the latest local main.

This is a simple habit that can prevent many avoidable integration problems.


29. A Practical Daily Git Workflow

For many developers, a normal work session might look like this:

Diagram / Architecture

Start the Day

bash
git switch main
git pull

Create a Feature Branch

bash
git switch -c feature/user-profile

Work on the Feature

Modify your files.

Check Changes

bash
git status
git diff

Stage Changes

bash
git add .

Review Staged Changes

bash
git diff --staged

Commit

bash
git commit -m "Add user profile page"

Push

bash
git push -u origin feature/user-profile

Create a Pull Request

Open the Pull Request on your Git hosting platform and describe the changes.


30. The Most Important Git Commands

If you're a beginner, focus on these first:

CommandPurpose
git initCreate a repository
git cloneCopy a remote repository
git statusCheck repository status
git addStage changes
git commitSave changes to Git history
git logView commit history
git branchView branches
git switchSwitch branches
git mergeMerge branches
git pullGet and integrate remote changes
git pushSend commits to remote
git fetchDownload remote information
git diffView changes
git stashTemporarily store changes
git restoreRestore files or unstage changes
git remoteManage remote repositories

You don't need to memorize all of them on your first day.

Use them repeatedly and they will become familiar.


31. Git Commands Cheat Sheet

Keep this quick reference available while learning.

bash
# Check Git version
git --version

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

# Create repository
git init

# Clone repository
git clone <repository-url>

# Check status
git status

# Stage one file
git add filename

# Stage everything
git add .

# Commit changes
git commit -m "Describe the change"

# View history
git log

# Short history
git log --oneline

# Create and switch branch
git switch -c feature-name

# Switch branch
git switch main

# Merge branch
git merge feature-name

# Pull remote changes
git pull

# Fetch remote information
git fetch

# Push changes
git push

# Push a new branch
git push -u origin feature-name

# View remotes
git remote -v

# View changes
git diff

# View staged changes
git diff --staged

# Temporarily save changes
git stash

# Restore stashed changes
git stash pop

32. Git vs GitHub

These two names are often confused.

Git

Git is a distributed version-control system.

It runs on your computer and tracks changes to your project.

GitHub

GitHub is an online platform that hosts Git repositories and provides collaboration features.

Think of it like this:

Diagram / Architecture

You can use Git without GitHub.

You can also use other platforms that host Git repositories.


33. What Beginners Should Avoid

1. Committing Everything Without Checking

Don't blindly run:

bash
git add .
git commit -m "update"

Check your changes first.

Use:

bash
git status
git diff

2. Huge Commits

A commit containing weeks of unrelated changes is difficult to understand.

Prefer smaller, meaningful commits.

3. Poor Commit Messages

Avoid:

text
update
changes
final
test
abc

Prefer:

text
Add password validation
Fix mobile navigation
Update job search filters
Add API error handling

4. Committing Secrets

Never commit:

text
API keys
Passwords
Private credentials
Database secrets
Access tokens

Use environment variables and appropriate secret-management practices instead.

5. Working Directly on Main

For collaborative projects, feature branches are often safer.

Use a workflow such as:

Diagram / Architecture

34. A Simple Git Learning Plan

If you're completely new to Git, don't try to learn everything in one day.

Stage 1 — Basic Workflow

Learn:

text
git init
git status
git add
git commit
git log

Stage 2 — GitHub

Learn:

text
git clone
git remote
git push
git pull

Stage 3 — Branching

Learn:

text
git branch
git switch
git merge

Stage 4 — Working Safely

Learn:

text
git diff
git restore
git stash
git fetch

Stage 5 — Team Collaboration

Learn:

  • Pull Requests
  • Code reviews
  • Merge conflicts
  • Branch strategies
  • Commit conventions

This progression gives you a practical path without overwhelming you.


35. The Git Mental Model

The easiest way to remember Git is to think about the different stages of your work.

Diagram / Architecture

When you need changes from others:

Diagram / Architecture

Once this mental model becomes clear, individual Git commands become much easier to understand.


Final Thoughts

Git may seem complicated when you first encounter it.

You don't need to master every command.

Start with the core workflow:

Check → Stage → Commit → Push

Then gradually learn:

Branch → Switch → Pull → Merge → Review

The more you use Git on real projects, the more natural it becomes.

Learn the workflow first. Use Git every day. Keep your commits meaningful.


Quick Checklist

  • Install Git
  • Configure your Git identity
  • Create a repository
  • Understand git status
  • Stage changes with git add
  • Create commits with git commit
  • Read history with git log
  • Connect a repository to GitHub
  • Push code to GitHub
  • Clone repositories
  • Create feature branches
  • Switch between branches
  • Merge changes
  • Pull updates
  • Understand Pull Requests
  • Resolve merge conflicts
  • Use .gitignore
  • Never commit secrets
  • Review changes before committing

Check → Stage → Commit → Push → Collaborate.

Follow Us On Social Media

Stay connected for daily tech jobs, interview prep & updates

KaryvioKaryvio

Empowering developers and tech professionals with curated career guidance, tech job opportunities, and developer resources.

Explore

  • Articles & Stories
  • Tech Jobs
  • Resume ATS
  • All Resources

Partner

  • Advertise with us
  • Post a Job Listing
  • Personalized Feed

Stay in the loop

Get our weekly digest of tech trends, career opportunities, and tools.

© 2026 Karyvio. All rights reserved.

About·Privacy Policy·Disclosure

Comments (0)

    Be the first to share your thoughts.

Keep reading

AI Coding Agents: How Developers Should Use Them Effectively
AI & Machine LearningSep 18, 2026

AI Coding Agents: How Developers Should Use Them Effectively

AI coding agents can now do much more than autocomplete code. Learn how to use them for planning, implementation, testing, debugging, and code review while keeping developers in control of quality and security.

S
Sibun
6 min00
npm Package Management: package.json, Dependencies, Scripts, and Lockfiles
Developer ResourcesSep 13, 2026

npm Package Management: package.json, Dependencies, Scripts, and Lockfiles

Learn how npm manages JavaScript project dependencies, scripts, versions, and lockfiles. Build a practical Node.js project and understand package.json, npm install, npm scripts, devDependencies, and package-lock.json.

S
Sibun
13 min01
Python Programming Fundamentals: A Practical Guide From Beginner to Job-Ready
Developer ResourcesSep 12, 2026

Python Programming Fundamentals: A Practical Guide From Beginner to Job-Ready

Learn Python from the ground up with practical examples covering variables, data types, control flow, functions, collections, modules, exceptions, files, OOP, virtual environments, packages, testing, and real-world project structure.

S
Sibun
27 min00
React Form Validation: Build Forms with Real-Time Error Handling
Developer ResourcesOct 17, 2026

React Form Validation: Build Forms with Real-Time Error Handling

Learn how to build validated React forms with controlled inputs, real-time feedback, reusable validation logic, accessible error messages, and submission handling.

R
Reenu
8 min00

Trending now

  1. 01

    REST API Explained: A Practical Guide for Beginners

    21 min read

  2. 02

    JavaScript Concepts Every Frontend Developer Should Know

    21 min read

  3. 03

    Git Commands Every Developer Should Know: A Practical Guide for Beginners

    16 min read

  4. 04

    Frontend Developer Roadmap in 2026: What to Learn From Beginner to Job-Ready

    15 min read

  5. 05

    How to Get Your First Software Developer Job in 2026: A Practical Roadmap for Freshers

    11 min read

Browse by tag

#AI#AI Applications#AI Career#AI Careers#AI Developer#AI Development#AI Engineering
#AI Evaluation
#AI Hiring
#AI Jobs
#AI Models
#AI Programming
#AI Project
#AI Projects
#AI Skills
#AI Testing