Git Version Control Fundamentals
Introduction to Version Control
Version control is a critical system in software development that tracks and manages changes to source code over time. Git, as a distributed version control system, enables developers to collaborate, track modifications, and maintain a comprehensive history of project evolution.
Core Git Concepts
What is Git?
Git is an open-source version control system designed to handle projects of all sizes with speed and efficiency. It allows multiple developers to work simultaneously on the same project without conflicts.
Key Git Terminology
Term |
Description |
Repository |
A directory where Git tracks project files and version history |
Commit |
A snapshot of project changes at a specific point in time |
Branch |
An independent line of development |
Remote |
A shared version of the repository hosted on a server |
Setting Up Git on Ubuntu 22.04
## Update system packages
sudo apt update
## Install Git
sudo apt install git
## Verify installation
git --version
Creating and Initializing a Repository
## Create project directory
mkdir my-project
cd my-project
## Initialize Git repository
git init
## Configure user information
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Basic Git Workflow
graph TD
A[Working Directory] -->|Add| B[Staging Area]
B -->|Commit| C[Local Repository]
C -->|Push| D[Remote Repository]
Adding and Committing Files
## Add specific file
git add README.md
## Add all changes
git add .
## Commit changes
git commit -m "Initial project setup"
Understanding Git's Architecture
Git operates through three primary areas:
- Working Directory: Where files are modified
- Staging Area: Prepares changes for commit
- Repository: Stores permanent snapshot of changes
By leveraging these fundamental git basics, developers can effectively manage code, track software development progress, and implement robust code management strategies.