Git Overview
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git was created by Linus Torvalds in 2005 for development of the Linux kernel.
Key Features
- Distributed: Every clone is a full repository with complete history.
- Branching and Merging: Lightweight branching and easy merging capabilities.
- Speed: Designed for performance on both small and large projects.
- Data Integrity: SHA-1 hashing ensures project history integrity.
- Staging Area: Intermediate area where commits can be formatted.
- Open Source: Free to use with an active development community.
- Tool Ecosystem: Numerous GUI clients and integration tools available.
Installation & Setup
Installation Steps:
- Download the installer from official website
- Run the installer with default options (Windows) or use package manager (Linux/macOS)
- Configure your identity:
git config --global user.name "Your Name" git config --global user.email "your.email@example.com" - Set up SSH keys for secure authentication with remote repositories
Common Commands:
git init
Initialize a new Git repository.
git clone
Clone an existing repository.
git status
Show the working tree status.
git commit
Record changes to the repository.
Productivity Tips
Aliases
Create shortcuts for common commands in your ~/.gitconfig file:
[alias]
co = checkout
br = branch
ci = commit
st = status
Interactive Staging
Use git add -p to interactively stage changes.
Rebase vs Merge
Use rebase to maintain linear history, merge to preserve branch topology.
Git Hooks
Use client-side hooks to automate tasks like running tests before commits.