Git Basics
Learn the fundamentals of version control and collaborative coding.
Next Module: Merging1. Installation
First, install Git on your system using your package manager or distribution's package manager.
# Linux (Debian/Ubuntu)
sudo apt update && sudo apt install git
# macOS (Homebrew)
brew install git
# Windows (Git Bash)
Download from https://git-scm.com
2. Initializing Your Repository
Create a new Git repository in your project directory:
git init
3. Basic Commands
Common day-to-day Git usage:
Adding Files
git add
adds file(s) to your staging area
git add README.md
git add .
Making Commits
git commit
finalizes staged changes
# -m flag for small commit
git commit -m "Initial project setup"
4. Tracking Changes
Use git status
to check your repository status:
git status
5. Remote Repositories
Connecting to a remote (like GitHub):
# Add remote origin
git remote add origin https://github.com/username/project.git
# Push changes to GitHub
git push -u origin master
Ready to Keep Learning?
You've mastered the basics of Git. Now explore how to merge changes and handle conflicts in our next module.
Next: Merging