Git Repository Basics
Understanding Git Repositories
A Git repository is a fundamental concept in version control system that stores project files, tracks changes, and manages collaborative development. It serves as a central storage location for project history, allowing developers to track, manage, and collaborate on code effectively.
Repository Types and Initialization
Git supports two primary repository types:
Repository Type |
Description |
Initialization Command |
Local Repository |
Stored on individual developer's machine |
git init |
Remote Repository |
Hosted on platforms like GitHub |
git clone <repository-url> |
Creating a Local Repository
## Create a new project directory
mkdir my-project
cd my-project
## Initialize a new Git repository
git init
## Verify repository initialization
ls -la
Repository Structure
graph TD
A[Git Repository] --> B[.git Directory]
A --> C[Working Directory]
A --> D[Staging Area]
B --> E[Configuration Files]
B --> F[Commit History]
B --> G[Branch Information]
Basic Git Commands for Repository Management
## Check repository status
git status
## Add files to staging area
git add .
## Commit changes
git commit -m "Initial project setup"
## View commit history
git log
Key Repository Concepts
Repositories track file changes through snapshots, enabling version control and collaborative development. Each commit represents a specific point in project history, allowing developers to revert, compare, and manage code modifications efficiently.