What is Git?
Git is a distributed version control system (DVCS) used to:
- track changes to files over time
- collaborate with multiple people on the same project
- manage branches independently
- sync code with GitHub or other remotes
Core features
- Version tracking: every change is recorded and can be reviewed later.
- Team collaboration: people can work in parallel on the same project.
- Branch management: separate work streams are created and merged later.
- Remote synchronization: the project can be pushed to GitHub for sharing.
Install Git
-
Download Git from git-scm.com
- macOS:
brew install git - Linux:
sudo apt update && sudo apt install git
- macOS:
-
Check installation
git --version
- Configure your identity
git config --global user.name "your name"
git config --global user.email "your email"
git config --list
GitHub integration
- Register on GitHub
- Create a repository
- Generate an SSH key and add it to GitHub
ssh-keygen -t ed25519 -C "your-email"
cat ~/.ssh/id_ed25519.pub
ssh -T git@github.com
To link a local project to a remote repository:
git remote add origin "your-remote-url"
Basic workflow
clone → branch → edit → add → commit → push → PR
Clone a repository
git clone <ssh-or-https-url>
Check status
git status
git branch
Create a branch
git switch -c feature/update-thing
Stage changes
git add .
git add -p
Commit changes
git commit -m "update message"
Push to remote
git push -u origin <branch-name>
Branch strategy
A branch is an independent line of work. It allows multiple developers to work without interfering with one another.
| Task | Command |
|---|---|
| List branches | git branch |
| Create branch | git switch -c feature/login |
| Switch branch | git switch main |
| Merge branch | git merge feature/login |
| Rebase branch | git rebase main |
| Delete branch | git branch -d feature/login |
Summary
Git is the standard tool for version control in software development. It makes collaboration safer, improves traceability, and gives teams a clear way to manage change.