PRACTICAL 1:
Installation and Configuration of Git
Aim
To install Git on the system, configure user credentials, and verify its proper working for
version control operations.
Introduction
Git is a distributed version control system that allows developers to track changes in their
source code and collaborate efficiently. It is widely used in modern software development
and DevOps environments to maintain code history and ensure smooth teamwork.
Version control systems like Git help developers manage changes, maintain multiple
versions of files, and coordinate work among multiple team members without conflicts.
Theory
Git was developed by Linus Torvalds in 2005 to support the development of the Linux
kernel. Unlike centralized version control systems, Git follows a distributed approach,
meaning every user has a complete copy of the repository.
Git uses a snapshot-based system instead of storing differences between files. This
makes it faster and more efficient.
Key Concepts of Git
• Repository (Repo): A storage location where project files are maintained
• Commit: A snapshot of changes made to files
• Staging Area: Intermediate area where changes are prepared before committing
• Branch: A parallel version of the repository
• Merge: Combining changes from different branches
1
Practical 1 DevOps Lab
Key Features of Git
• Distributed version control system
• High performance and speed
• Strong data integrity using SHA-1 hashing
• Efficient branching and merging capabilities
• Supports offline work
Importance in DevOps
Git plays a crucial role in DevOps practices:
• Enables continuous integration and deployment
• Helps in tracking code changes efficiently
• Supports collaboration among development teams
• Integrates with tools like Jenkins, Docker, and Kubernetes
Advantages
• Fast and efficient operations
• Complete history of changes
• Easy collaboration among developers
• Backup and recovery of projects
• Supports branching for parallel development
Procedure
Step 1: Install Git
For Linux (Ubuntu/Debian):
sudo apt update
sudo apt install git -y
For Windows:
• Visit the official Git website
• Download the installer
• Run the setup and follow default settings
2
Practical 1 DevOps Lab
Step 2: Verify Installation
After installation, verify Git by checking its version:
git --version
This command confirms that Git is installed correctly.
Step 3: Configure User Details
Set up your username and email, which will be associated with your commits:
git config --global [Link] "Your Name"
git config --global [Link] "your@[Link]"
To verify configuration:
git config --list
Step 4: Initialize a Repository
Create a new project directory and initialize Git:
mkdir demo-project
cd demo-project
git init
This creates a hidden .git folder to track changes.
Step 5: Create and Add Files
Create a file and add it to the staging area:
echo "Hello Git" > [Link]
git add [Link]
Step 6: Commit Changes
Save the changes to the repository:
git commit -m "Initial commit"
Step 7: Check Repository Status
Check the current state of the repository:
git status
3
Practical 1 DevOps Lab
Working Explanation
• Git tracks changes in files through commits
• The staging area allows selective commits
• Each commit stores a snapshot of the project
• Git ensures data integrity using hashing
Applications
• Software development projects
• Team collaboration in organizations
• DevOps pipelines and automation
• Open-source project management
Result
• Git installed successfully on the system
• User credentials configured correctly
• Repository initialized successfully
• File added and committed without errors
• Repository status verified successfully
Conclusion
Git is an essential tool for version control and plays a vital role in DevOps workflows.
It enables efficient collaboration, maintains code history, and ensures reliable software
development practices.
Output Screenshot