Fundamentals 20 min read

Master Version Control: From Basics to Advanced Git Operations

This comprehensive guide explains what version control systems are, compares local, centralized, and distributed models, walks through installing Git, essential commands, branch management, remote repositories, SSH authentication, and IDE integration, providing a solid foundation for modern software development.

Open Source Linux
Open Source Linux
Open Source Linux
Master Version Control: From Basics to Advanced Git Operations

Version Control Tools

1.1 What is a Version Control System?

A Version Control System (VCS) records changes to one or more files over time so specific versions can be retrieved later; it can manage source code as well as any file type. Common VCSs include CVS, SVN, and Git.

1.2 Why Use a VCS?

During development files are frequently modified or deleted; a VCS preserves history without the complexity of manual backups.

In multi‑person projects, VCS simplifies collaboration and reduces merge conflicts.

1.3 Types of VCS

Local VCS : Records changes on a single machine; unsuitable for team collaboration.

Centralized VCS (e.g., SVN, CVS): Requires a central server for storing versions; dependent on network connectivity and server availability.

Distributed VCS (e.g., Git): Each user has a full repository copy, works offline, and synchronizes with others when network is available.

2. Git

2.1 Introduction

Git is a free, open‑source distributed version control system designed for fast, efficient handling of projects of any size.

Git was created by Linus Torvalds to help manage Linux kernel development.

2.2 Installation

Recommended Chinese mirror download: http://npm.taobao.org/mirrors/git-for-windows (avoid installing in a Chinese‑named directory or using desktop management tools).

After installation, right‑click in any folder to confirm successful setup.

2.3 Basic Usage

Initialize a repository: git init Check status: git status Add files to the staging area: git add <filename> Commit staged changes: git commit -m 'message' View commit log:

git log
# Initialize repository (creates .git folder)
git init
# Show status (untracked files appear)
git status
# Add a file to staging
git add index.html
# Commit with a message
git commit -m 'first commit'
# View log
git log

2.4 Configuring User Info

Set name and email for the first use (local repository only):

git config user.name YourName
git config user.email [email protected]

Use --global to apply settings globally.

2.5 Working Principle

Git tracks three areas: Working Directory, Staging Area (Index), and Repository. Changes flow from Working Directory → Staging Area → Repository.

2.6 Detailed Commands

git add

Add specific file: git add file.txt Add all changes: git add . or git add -A Add pattern:

git add *.js

git checkout

Restore files from staging to working directory:

git checkout filename

git commit

Commit staged files:

git commit -m
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.