Git Basics for Beginners
What is Git?
Git is a distributed version control system (VCS) designed to track changes in source code during software development. As a powerful source code management tool, Git enables developers to collaborate efficiently, manage project versions, and maintain code history.
Key Concepts in Git
Version Control System
A version control system helps developers manage and track changes in their codebase. Git provides several essential features:
Feature |
Description |
Tracking Changes |
Record modifications in source code |
Collaboration |
Multiple developers can work simultaneously |
Version History |
Maintain complete project history |
Branching |
Create independent development lines |
Git Repository Structure
graph TD
A[Working Directory] --> B[Staging Area]
B --> C[Local Repository]
C --> D[Remote Repository]
Installing Git on Ubuntu 22.04
sudo apt update
sudo apt install git
git --version
Configuring Git
## Set global user name
git config --global user.name "Your Name"
## Set global email
git config --global user.email "[email protected]"
Creating a Git Repository
## Initialize a new repository
mkdir my-project
cd my-project
git init
## Clone an existing repository
git clone
Basic Git Workflow
## Check repository status
git status
## Add files to staging area
git add filename.txt
git add .
## Commit changes
git commit -m "Initial commit message"
## View commit history
git log