Fundamentals 10 min read

Master Git vs SVN: Core Concepts, Commands, and Git‑SVN Integration

This guide compares Git and SVN, explains Git's core workflow, provides essential commands for everyday use, and shows how to bridge SVN repositories with Git‑SVN, offering a complete reference for developers transitioning between the two version‑control systems.

ITPUB
ITPUB
ITPUB
Master Git vs SVN: Core Concepts, Commands, and Git‑SVN Integration

Git vs SVN

Git is a distributed version‑control system; SVN is centralized. Git supports offline work, cheap branching, and a richer command set, while SVN requires network access and creates branches by copying directories.

Core Git concepts

The three main areas are:

Workspace : the working directory on your computer.

Index (staging area) : a temporary cache for changes before committing.

Repository : stores the history, both locally and remotely.

Understanding the index and the local repository is the biggest hurdle for SVN users.

Typical commit workflow

git add

– move changes from workspace to index. git commit – record index changes into the local repository. git push or git svn dcommit – send local commits to the remote repository.

Git‑SVN common commands

# Clone an SVN project with full history into a Git repo
git svn clone -s [repository]

# Show repository info
git svn info

# Fetch all remote branches
git svn fetch

# Rebase local changes onto remote
git svn rebase

# Commit local changes back to SVN
git svn dcommit

# Create a local branch that tracks a remote SVN branch
git checkout -b [local_branch] [remote_branch]

Repository initialization

# Initialize a new Git repository in the current directory
git init

# Clone a remote Git project
git clone [url]

Configuration

# List all config values
git config -l

# Set useful aliases
git config --global alias.co checkout
git config --global alias.ci commit
git config --global alias.st status
git config --global alias.br branch

# Set user information
git config --global user.name "[name]"
git config --global user.email "[email address]"

Global config is stored in ~/.gitconfig; repository‑specific config resides in .git/config.

Adding and removing files

# Add all files
git add .

# Add specific files
git add <file1> <file2>

# Remove files and stage the deletion
git rm <file1> <file2>

# Stop tracking a file but keep it in the workspace
git rm --cached <file>

# Rename a file
git mv <old> <new>

Branch management

# List local branches
git branch

# List all branches (local + remote)
git branch -a

# Create a new branch
git branch <branch-name>

# Create and switch to a new branch
git checkout -b <new_branch> <remote-branch>

# Switch to an existing branch
git checkout <branch-name>

# Merge a branch into the current one
git merge <branch>

# Cherry‑pick a specific commit
git cherry-pick <commit>

# Delete a local branch
git branch -d <branch-name>

# Delete a remote branch
git push <remote> :<remote-branch>

Committing

# Commit with a message
git commit -m "[message]"

# Commit all changes (skip staging)
git commit -a

# Show diff in the commit output
git commit -v

# Amend the previous commit
git commit --amend -m "[new message]"

# Push a branch to remote
git push <remote> <remote-branch>

Fetching and pulling

# Fetch all changes from remote (Git only)
git fetch <remote>

# Show remote URLs
git remote -v

# Pull and merge
git pull <remote> <branch>

# Pull with rebase
git pull --rebase <remote> <branch>

Undoing changes

# Restore a file from index
git checkout <file>

# Restore all files in the current directory
git checkout .

# Reset index to match a commit (keep workspace)
git reset <file>

# Hard reset index and workspace
git reset --hard

# Revert a commit
git revert <commit>

# Stash uncommitted changes
git stash

# Apply stashed changes
git stash pop

Querying the repository

# Show status of working tree
git status

# Show diff of a file
git diff <file>

# Show staged diff
git diff --cached <file>

# Show commit log
git log

# Filter log by author
git log --author=someone

# Show changes for a specific file
git log -p <file>

# Show details of a commit
git show <commit>

Images

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.

workflowGitVersion ControlcommandsbranchingGit-SVNsvn
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.