Git
Version control for your code
Git is the most popular version control system. It tracks changes to your code, lets you collaborate with others, and is essential for modern development.
Git Basics
Check Status
git status
Shows which files have changed.
Stage Changes
git add filename.txt
Stage a specific file.
git add .
Stage all changed files.
Commit Changes
git commit -m "Add login feature"
Save staged changes with a message.
View History
git log --oneline
Shows commit history in a compact format.
Set Up SSH Keys for GitHub
SSH keys let you push/pull from GitHub without entering your password every time.
-
Generate an SSH key:
Ubuntu
ssh-keygen -t ed25519 -C "[email protected]"Press Enter to accept the default location. You can add a passphrase or leave it empty.
-
Start the SSH agent:
Ubuntu
eval "$(ssh-agent -s)" -
Add your key to the agent:
Ubuntu
ssh-add ~/.ssh/id_ed25519 -
Copy your public key:
Ubuntu
cat ~/.ssh/id_ed25519.pubCopy the entire output (starts with
ssh-ed25519). -
Add to GitHub:
- Go to GitHub SSH Keys
- Click "New SSH key"
- Give it a title (e.g., "WSL Ubuntu")
- Paste your public key
- Click "Add SSH key"
-
Test the connection:
Ubuntu
ssh -T [email protected]You should see "Hi username! You've successfully authenticated..."
Clone a Repository
To download a repository from GitHub:
git clone [email protected]:username/repo.git
This creates a folder with the repository contents.
LazyGit - Visual Git Interface
LazyGit is a terminal UI for Git that makes complex operations visual and intuitive. The bootstrap script installed it for you.
lazygit
Run this inside any Git repository to open the interface.
LazyGit Panels
| Panel | Purpose |
|---|---|
| Status | Current branch and repo state |
| Files | Changed files (stage with Space) |
| Branches | Local and remote branches |
| Commits | Commit history |
| Stash | Stashed changes |
Common LazyGit Keys
| Key | Action |
|---|---|
| Space | Stage/unstage file |
| c | Commit staged changes |
| p | Push to remote |
| P | Pull from remote |
| n | New branch |
| Enter | View diff/details |
| ? | Show all keybindings |
| q | Quit |
LazyGit has many more features. Press ? in any panel to see all available keybindings for that context.