Git Repository Fundamentals
Understanding Git Version Control
Git is a distributed version control system designed to track changes in source code during software development. It enables multiple developers to collaborate efficiently by managing file modifications, branching, and merging.
Creating a New Git Repository
To initialize a new Git repository, use the git init
command:
mkdir my-project
cd my-project
git init
This command creates a hidden .git
directory that stores all repository metadata and version history.
Repository Configuration
Configure your Git identity with global settings:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Configuration Option |
Purpose |
user.name |
Sets your commit author name |
user.email |
Sets your commit email address |
Basic Repository Workflow
graph LR
A[Working Directory] --> B[Staging Area]
B --> C[Local Repository]
C --> D[Remote Repository]
Key Git commands for repository management:
git status
: Check repository state
git add
: Stage files
git commit
: Save changes locally
git push
: Upload changes to remote repository
File Tracking Mechanisms
Git tracks files through three main states:
- Untracked
- Modified
- Staged
Example of file tracking:
## Check repository status
git status
## Add specific file
git add README.md
## Add all files
git add .
## Commit changes
git commit -m "Initial project setup"