Version Control with Git (Part 1)
Week 3: Introduction to Git and
Version Control
Session Objectives
• By the end of this session, students will:
– Understand the basics of Git and its importance in
DevOps.
– Comprehend the need for version control in
software development.
– Compare centralized and distributed version
control systems.
Introduction to Git
– Git is a distributed version control system.
– Tracks changes in source code during software
development.
– Facilitates collaboration among multiple
developers.
Importance of Git in DevOps
– Collaboration: Enables multiple developers to
work together efficiently.
– Continuous Integration: Integrates seamlessly with
CI/CD tools.
– Track History: Maintains a detailed history of
changes.
– Branching and Merging: Supports parallel
development workflows.
Git Basic Features
– Snapshots: Git stores snapshots of the file system.
– Branching: Allows work on different features
simultaneously.
– Distributed Nature: Every developer has a full copy
of the repository.
– Offline Work: Enables development without a
network connection.
Basic Git Commands
– git init: Initialize a new Git repository.
– git clone: Clone an existing repository.
– git add: Add files to the staging area.
– git commit: Commit changes to the local
repository.
– git push: Push commits to a remote repository.
– git pull: Fetch and merge changes from a remote
repository.
The Need for Version Control
– Preventing Overwrites: Avoids conflicts when
multiple developers edit the same file.
– Collaboration: Facilitates teamwork and parallel
development.
– Backup and Recovery: Ability to revert to previous
versions if needed.
– Traceability: Tracks who made changes and when.
Centralized Version Control
Systems (CVCS)
– Definition: Single central repository that all
developers synchronize with.
– Examples: Subversion (SVN), Perforce.
– Pros: Simple setup and administration, centralized
control and security.
– Cons: Single point of failure, limited offline
capabilities.
Distributed Version Control
Systems (DVCS)
– Definition: Each developer has a complete copy of
the repository.
– Examples: Git, Mercurial.
– Pros: Full history available offline, no single point
of failure, efficient branching and merging.
– Cons: Steeper learning curve, potentially larger
local storage requirements.
Comparison: CVCS vs. DVCS
– Server Dependency: CVCS - Dependent on central
server; DVCS - No central server required for most
operations.
– Offline Work: CVCS - Limited functionality offline;
DVCS - Full functionality offline.
– Performance: CVCS - Slower with large teams;
DVCS - Scales well with team size.
– Branching/Merging: CVCS - Can be complex and
error-prone; DVCS - Seamless and efficient.
Homework Assignment
– Research and compare different version control
systems (e.g., SVN, Git, Mercurial, Perforce).
– Focus on pros, cons, and use cases of each system.
– Prepare a short report (1-2 pages) summarizing
your findings.
Q&A
– Questions and Discussion: Encourage students to
ask questions about Git and version control
systems.
– Open floor for discussions and clarifications.