Unit 1 - Introduction
Concept of Version Control System
A Version Control System (VCS) is a software tool or system that helps in
managing changes to source code, documents, or any other collection of files over
time. It provides a systematic way to track, manage, and coordinate changes
made by multiple contributors to a project. The primary purpose of a VCS is to
ensure the integrity, traceability, and collaboration of a project's assets.
There are two main types of version control systems:
1. Centralized Version Control System (CVCS): In a CVCS, there is a central server
that stores the entire history and versions of files. Users check out files from the
central repository to work on them and then check them back in when they are
done. Examples of CVCS include CVS (Concurrent Versions System), Perforce and
Subversion (SVN).
Advantages:
- Centralized control and management of files.
- Simplified access control and permissions.
- Single point of backup and recovery.
Disadvantages:
- Single point of failure (if the central server goes down, users cannot access the
repository).
- Limited offline functionality.
Unit 1 - Introduction
- Slower performance for operations that involve the central server.
2. Distributed Version Control System (DVCS): In a DVCS, every user has a
complete copy of the repository, including its history, on their local machine.
Users can work independently and commit changes to their local repository.
Changes can then be shared with others by pushing them to a remote repository.
Examples of DVCS include Git, Mercurial, and Bazaar.
Advantages:
- Decentralized and offline work capabilities.
- Faster local operations since they don't require communication with a central
server.
- Greater flexibility for branching and merging.
Disadvantages:
- More complex setup and learning curve compared to CVCS.
- Potentially larger disk space requirements due to full repository copies on each
user's machine.
- Advanced workflows might require more careful coordination.
Key concepts in version control include:
1. Repository: A storage location where all the project's files, history, and
metadata are stored.
Unit 1 - Introduction
2. Commit: A snapshot of changes made to the repository. Each commit is
accompanied by a message explaining the changes.
3. Branch: A separate line of development that diverges from the main line
(usually called the "master" or "main" branch). Branches allow for the parallel
development of different features or bug fixes.
4. Merge: Combining changes from one branch into another, usually to
incorporate new features or bug fixes into the main branch.
5. Pull/Push: In DVCS, "pull" refers to getting changes from a remote repository
into your local repository, and "push" is the action of sending your local changes
to a remote repository.
6. Conflict: When a VCS cannot automatically merge changes from different
sources due to conflicting edits in the same part of a file. Resolving conflicts
requires manual intervention.
Version control systems play a crucial role in enabling collaboration, maintaining a
history of changes, and facilitating efficient software development and project
management processes. Git, which is a distributed version control system, has
become one of the most widely used tools in the software development industry.
Unit 1 - Introduction
What is GIT?
Git is a widely used distributed version control system (DVCS) designed to track
changes in source code during software development. It was created by Linus
Torvalds in 2005 for managing the development of the Linux kernel, but it has
since become a standard tool in the software development industry for managing
version control and collaboration.
Key features of Git include:
1. Distributed Nature: Unlike centralized version control systems, every Git
user has a complete copy of the repository, including its entire history, on
their local machine. This allows for offline work, faster operations, and a
high degree of redundancy.
2. Branching and Merging: Git provides powerful branching and merging
capabilities, allowing developers to work on separate features or bug fixes
in isolated branches. Branches can be easily created, merged, and deleted,
making parallel development much smoother.
3. Fast and Efficient: Git is designed to be fast and efficient. Local operations,
such as committing changes, creating branches, and switching between
branches, are lightning-fast due to the distributed nature of the system.
4. Data Integrity: Git uses cryptographic hashing to ensure the integrity of
data. This means that once a commit is made, its content cannot be altered
without changing the hash, providing a strong mechanism to verify the
integrity of the repository's history.
5. History Tracking: Git maintains a complete and detailed history of changes
made to files, making it easy to trace back and understand the evolution of
the project.
6. Collaboration: Git facilitates collaboration by allowing developers to share
their work with others through remote repositories. Multiple developers
Unit 1 - Introduction
can work on the same project simultaneously without interfering with each
other's work.
7. Staging Area: Git introduces the concept of a staging area (also known as
the index), where changes are prepared for a commit. This allows
developers to selectively choose which changes to include in the next
commit.
8. Open Source: Git is open-source software, meaning that its source code is
freely available for anyone to inspect, modify, and contribute to.
9. Large Ecosystem: Git has a vast and active community, resulting in a rich
ecosystem of tools, extensions, and integrations that enhance its
functionality and adapt it to various workflows.
Benefits of Git
A version control application allows us to keep track of all the changes that we
make in the files of our project. Every time we make changes in files of an existing
project, we can push those changes to a repository. Other developers are allowed
to pull your changes from the repository and continue to work with the updates
that you added to the project files.
Some significant benefits of using Git are as follows:
Unit 1 - Introduction
o Saves Time
Git is lightning fast technology. Each command takes only a few seconds to
execute so we can save a lot of time as compared to login to a GitHub
account and find out its features.
o Offline Working
One of the most important benefits of Git is that it supports offline
working. If we are facing internet connectivity issues, it will not affect our
work. In Git, we can do almost everything locally. Comparatively, other CVS
like SVN is limited and prefer the connection with the central repository.
o Undo Mistakes
One additional benefit of Git is we can Undo mistakes. Sometimes the undo
can be a savior option for us. Git provides the undo option for almost
everything.
o Track the Changes
Git facilitates with some exciting features such as Diff, Log, and Status,
which allows us to track changes so we can check the status, compare our
files or branches.
Git Repository Structure
It consists of 4 parts:
1. Working directory: This is your local directory where you make the project
(write code) and make changes to it.
2. Staging Area (or index): this is an area where you first need to put your
project before committing. This is used for code review by other team
members.
3. Local Repository: this is your local repository where you commit changes to
the project before pushing them to the central repository on Github. This is
Unit 1 - Introduction
what is provided by the distributed version control system. This
corresponds to the .git folder in our directory.
4. Central Repository: This is the main project on the central server, a copy of
which is with every team member as a local repository.
Git Vs GitHub
1. Git:
Git is a distributed version control system (DVCS) that helps you track
changes to your source code and manage different versions of your
project files.
It provides local repositories on each developer's machine, allowing
them to work offline and commit changes without the need for a
constant network connection.
Git facilitates branching, merging, history tracking, and efficient local
operations.
It focuses on the core version control functionality and does not
provide a graphical user interface by default.
2. GitHub:
GitHub is a web-based platform that utilizes Git for version control
but adds a layer of collaboration, social interaction, and project
management tools on top of Git.
It provides a centralized location (repository) for hosting Git
repositories, making them accessible from anywhere with an internet
connection.
GitHub offers features like pull requests, issue tracking, code reviews,
and project boards to streamline collaboration among developers.
Unit 1 - Introduction
It allows developers to easily contribute to open-source projects,
submit changes (pull requests), and discuss code changes using
comments.
GitHub provides a user-friendly web interface for interacting with Git
repositories and managing collaboration.