Software Engineering

Version Control

Michael L. Collard, Ph.D.

Department of Computer Science, The University of Akron

SCM

Software Configuration Management

  • Tracking and controlling changes to files used in software development
  • Based on revision control (version control)
  • Used for managing builds and releases
  • Used for accounting and auditing of the process and product

We use version control for …

  • Coordinating source code for a particular release
  • Collecting metrics on software productivity
  • Studying the process of development
  • Informing non-developers of the current state of the source code
  • Bringing new and absent developers up to date

Version Control (Revision Control)

After an editor and a compiler, version control is the most crucial tool for software development

  • Essential to the coordination of changes among collaborating developers
  • Essential to a solitary developer working on anything non-trivial
  • Maintains a history of changes
  • Management of branches and product families
  • Defines the workflow
  • All parts of development revolve around version control
  • Everything in modern software development depends on version control

Version Control vs. Shared Directory

Version Control (e.g., Git) Shared Directory
Tracks history of every change Only a snapshot at one moment
Shows authorship of each change No authorship information
Allows reverting to earlier versions No rollback, must unpack copies
Supports branching and merging Single linear copy only
Enables collaboration with multiple users Must manually share updated files
Detects and resolves conflicts Silently overwrites changes
Stores differences efficiently (deltas) Full copy of every file for every "version"
Integrates with automation No built-in automation support
Provides commit messages for context No explanation of changes
Ensures integrity with hashes Integrity depends on archive tool
Each change can be signed/verified Only the entire archive can be signed/verified
Treats development as iterative Treats development as static

diff and patch

  • Distribute changes efficiently
  • Simplistic form of handling versions
  • diff utility creates a patch file
  • The patch utility applies the patch file to the starting code to create the updated file

Ex: Create a Patch



hello.cpp

Ex: Apply a Patch

hello.cpp

iostream.patch

Common Features

  • Versioning down to file level
  • Text Files: Only understands the lexical level (i.e., a source-code file is a file of characters)
  • No understanding of the syntactic structure of code
  • Does not know what a while statement is
  • Binary Files: Stay at the file level

Management Models

Management Model: File Locking

  • Only one developer at a time has access to a file/resource
  • Lock-Modify-Unlock
  • One developer at a time has the "token"; other developers have to wait
  • Library model
  • Advantage: No merging problems
  • Disadvantage: Prevents other developers from working
  • Disadvantage: Impractical for distributed development due to time differences

Management Model: Version Merging

  • No restrictions on access
  • Developers can work simultaneously
  • Copy-Modify-Merge
  • Advantage: No restrictions on working
  • Disadvantage: Merge issues

Current Practice

  • A large majority of the usage of version control is Version Merging
  • File Locking is typically only used for binary files (e.g., MS Word files)
  • May find old projects (and developers) that use File Locking

Version Control

  • SCCS
  • RCS
  • CVS
  • SVN
  • Git

SCCS (Source Code Control System)

  • Developed in the early 1970s at Bell Labs (primarily by Marc J. Rochkind)
  • One of the first systems to track changes in source code, storing differences (deltas) to reconstruct versions
  • Operated on a file-by-file basis, with locking-based concurrency (only one user could modify a file at a time)
  • Utilized weave files, which interwove different revisions of code into the same file

SCCS Commands

Command Description
sccs create <file> Initialize SCCS control for <file> (creates SCCS/s.<file>)
sccs edit <file> Check out <file> for editing (exclusive lock)
sccs delta <file> Check in the file (creating a new delta/revision in SCCS/s.<file>)
sccs get <file> Retrieve a read-only copy of <file> (no lock)
sccs diffs <file> Show differences between revisions
prs SCCS/s.<file> Print the SCCS file history (log of changes, etc.)

RCS (Revision Control System)

  • Developed in the early 1980s by Walter Tichy at Purdue University
  • Introduced improvements over SCCS, such as reverse deltas
  • Also uses a file-by-file approach and locking mechanisms
  • Metadata about changes stored in RCS files, typically ending in ",v"

RCS Commands

Command Description
rcs -i <file> Initialize RCS control for <file> (creates RCS/<file>,v)
co -l <file> Check out <file> for editing (exclusive lock)
ci <file> Check in <file> (creating a new revision in RCS/<file>,v)
co <file> Retrieve a read-only copy of <file> (no lock)
rcsdiff [options] <file> Show differences between revisions of <file>
rlog <file> Print information about the RCS file history (log of changes, etc)

CVS (Concurrent Versions System)

  • Developed in the 1980s, built on top of RCS
  • Moved beyond strict locking; introduced concurrent development by merging changes.
  • Provided a client-server architecture, allowing multiple developers to collaborate.
  • Became very popular in open-source projects throughout the 1990s and early 2000s.

CVS Commands

Command Description
cvs init Initialize a CVS repository in the current directory
cvs checkout <module> Check out <module> into a working directory
cvs update Update local files with changes from the CVS repository
cvs commit Commit local changes to the repository
cvs diff Show differences between working copy and repository
cvs log Print log messages for files

SVN (Apache Subversion)

  • Developed in 2000 by CollabNet, later an Apache project
  • Aimed to be a compelling replacement for CVS, addressing its shortcomings
  • Uses a centralized repository model but improves support for atomic commits, better handling of file renames, and efficient branching/tagging
  • Widely adopted in many corporate environments before distributed version control became popular

SVN Commands

Command Description
svnadmin create <repo_path> Create an empty Subversion repository at <repo_path>
svn checkout <repo_url> Check out a working copy from <repo_url>
svn update Update working copy to the latest revision from the repository
svn commit -m "message" Commit changes from the working copy to the repository
svn diff Show differences between the working copy and the repository
svn log Print log messages for files or directories

Git

  • Developed in 2005 by Linus Torvalds for the development of the Linux kernel
  • Distributed version control system (DVCS): each clone of a repository is a fully-fledged repository with a complete version history
  • Focuses on speed, non-linear development, and data integrity
  • Popularized branching and merging as everyday, lightweight tasks
  • De facto standard for version control in modern software development (used on platforms like GitHub, GitLab, Bitbucket, etc.)

Git Commands

Command Description
git init Initialize a new Git repository in the current directory
git clone <repo_url> Clone a repository from <repo_url> into a new directory
git pull Retrieve and merge changes from the remote repository into the local one
git add <file> Stage <file> for the next commit
git commit -m "message" Commit staged changes with the message "message"
git push Send local commits to the remote repository
git diff Show differences between the working copy and the repository
git log Print the log of commits, including messages

Version Control Command Comparison

SCCS RCS CVS SVN Git
sccs create <file> rcs -i <file> cvs init svnadmin create <repo_path> git init
sccs edit <file> co -l <file> cvs checkout <module> svn checkout <repo_url> git clone <repo_url>
sccs delta <file> ci <file> cvs commit svn commit -m "<msg>" git commit -m "<msg>"
sccs get <file> co <file> cvs update svn update git pull
sccs diffs <file> rcsdiff <file> cvs diff svn diff git diff
prs SCCS/s.<file> rlog <file> cvs log svn log git log

Centralized Version Control

Centralized Version Control

  • e.g., Subversion (SVN), ClearCase, Vault
  • A single central repository, local working copies
  • Access controlled by the server
  • One sequence of version numbers
  • Traditional approach

SVN View

  • (remote) repository:
  • The single, central SVN repository typically running on a remote machine
  • working copy:
  • Sometimes referred to as a local repository, but it is not
  • The code you checked out into your filesystem
  • Where you modify your files

SVN

  • Versions identified by monotonically increasing numbers
  • URLs identify both the location of a central repository and directories/files in the central repository
  • Each commit has an author
  • Support for per-directory permissions, with some limitations

Common SVN Issues

  • Need access to a server to create a shared repository
  • No distinction between private and public changes
  • Merging is difficult
  • Branching creates problems

Distributed Version Control

Distributed Version Control

  • e.g., Git, Bazaar, Darcs, Mercurial, Monotone, SVK
  • Peer-to-peer, no central repository; all are repository copies
  • No one sequence of version "numbers" (Why?)
  • Access controlled by the server

Git

  • Distributed revision control and SCM (Source Code Management) system
  • Created in 2005 by Linus Torvalds for Linux kernel development
  • Used by major companies, e.g., Microsoft, Apple
  • Built-in to many IDEs
  • Fluency in Git is a requirement for anybody in software engineering

Git View

  • repository
  • Stored in the (hidden) directory .git
  • What you clone from another repository
  • working copy
  • The code you checkout into your filesystem
  • The files that you see
  • Where you modify the file

Git Characteristics

  • Each commit has a hash, currently a SHA1 id (160-bit numbers in hexadecimal)
  • Each commit has an author and a committer
  • peer-to-peer
  • The URL only identifies the repository's location. The repository should always have branches and tags, and the default branch is the "main" (previously "master").
  • Each copy is a full-fledged repository and can be worked on locally without access to a central server
  • Each user clones the repository, makes changes, and pushes the changes

Git Benefits

  • Records complete new version
  • Handles local and remote repositories
  • Tracks merged data
  • Staging changes

Git Comparison

  • Advantages: fast, flexible, powerful, multiuser
  • Disadvantages: complex, challenging to learn, GUI tools less developed than SVN tools
  • Despite disadvantages, Git is a standard tool for software engineering and software development in general
  • Also used as a data format for applications
  • Example: brew is built on top of Git

GitHub

  • One issue with Git is that to collaborate with others, your repository must be public
  • GitHub is a hosting service for software development projects using Git
  • Web-based hosting site for Git repositories
  • About 420 million repositories, over 150 million users
  • Founded in 2008, Microsoft purchased it in 2018
  • An account at GitHub is necessary for software development and software engineering (not just this class)

Software Ecosystems

Git Influence

  • Microsoft:
  • Visual Studio Online 2015
  • Visual Studio Blog: Git
  • Azure Repos
  • Apple:
  • Current: XCode 26 and macOS Tahoe 26
  • XCode - Git/SVN support through XCode 8
  • XCode 9: Dropped SVN support
  • XCode 11: SVN deprecated
  • macOS Catalina 10.15: SVN no longer installed on the command line

Git Tools

Recommendation: command-line Git

  • Command-line git is the proper Git; everything else is an approximation
  • Most answers to Git questions show the command-line answer
  • As you use the command line, you start to remember commands (not the case in GUIs)
  • Often, the GUI "easy" solutions are not the only way to fix a problem and are often not the best
  • GUIs overlays proper git and try to make it simpler, but they fail
  • Can script/automate command-line solutions

Platform

  • Linux - Command-line git
  • macOS - Command-line git
  • Windows - Git Bash in Git for Windows Command-line git in WSL