11. Interfaces - ivomac/GitBasics GitHub Wiki

πŸ“Ί Git CLI

  • πŸ–₯️ Git is a command line program. All other git interfaces are wrappers of git.
  • πŸ’ͺ Learning CLI gives you complete control and understanding of Git operations.
  • πŸ“š The CLI is extensive and heavy. TUIs/GUIs can make using git much easier.
  • Docs at https://git-scm.com/docs/user-manual.

πŸ“Ί Essential CLI Commands

πŸ—οΈ Repository Setup

git init                    # Initialize new repository
git clone <url>             # Copy a repository
git remote add origin <url> # Define a remote called "origin"

πŸ“Έ Basic Operations

git help <command>          # Display help for a command
git status                  # Show working directory status
git add <file>              # Stage files for commit
git add .                   # Stage all changes
git commit -m "message"     # Create commit with message

πŸš€ lazygit

  • πŸš€ lazygit is a terminal-based Git interface that combines CLI power with visual convenience.
  • ⌨️ Provides an intuitive, keyboard-driven interface with vim-like navigation.
  • 🎨 Clear visual representation of repository state and history.
  • Source at https://github.com/jesseduffield/lazygit.
  • Video guide at https://youtu.be/VDXvbHZYeKY.

πŸš€ lazygit Interface Layout

 β”Œβ”€Statusβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”Œβ”€Unstaged changes─────────────────────────────────┐
 β”‚ β€’ On branch main         β”‚β”‚diff --git i/src/kiwi.py w/src/kiwi.py            β”‚
 β”‚ β€’ Your branch is up to   β”‚β”‚index 624c7b0..cca0eea 100644                     β”‚
 β”‚   date with origin/main  β”‚β”‚--- i/src/kiwi.py                                 β”‚
 β”‚ β€’ Changes to be commit.. β”‚β”‚+++ w/src/kiwi.py                                 β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚ @@ -20,4 +22,4 @@                                β”‚
 β”Œβ”€Files────────────────────┐│      for kiwi in kiwis:                          β”‚
 β”‚ MM  src/kiwi.py          β”‚β”‚ -        total += kiwi["price"]                  β”‚
 β”‚ A  tests/test_new.py     β”‚β”‚ +        total += kiwi.price                     β”‚
 β”‚ D  old_file.txt          β”‚β”‚      return total                                β”‚
 β”‚ ?? untracked.log         β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”Œβ”€Staged changes───────────────────────────────────┐
 β”Œβ”€Branches─────────────────┐│diff --git c/src/kiwi.py i/src/kiwi.py            β”‚
 β”‚ * main                   β”‚β”‚index fa576fb..624c7b0 100644                     β”‚
 β”‚   feature/mango          β”‚β”‚--- c/src/kiwi.py                                 β”‚
 β”‚   hotfix/kiwi_counting   β”‚β”‚+++ i/src/kiwi.py                                 β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚@@ -43,1 +44,4 @@                                 β”‚
 β”Œβ”€Commits──────────────────┐│                                                  β”‚
 β”‚ a1b2c3d Fix bug in id    β”‚β”‚+# Todo list:                                     β”‚
 β”‚ e4f5g6h Add kiwi counter β”‚β”‚+# - Retrieve prices/discounts from supermarkets. β”‚
 β”‚ i7j8k9l Update docs      β”‚β”‚+# - Setup alerts for big kiwi discounts.         β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🌲 SourceTree

  • πŸ–±οΈ SourceTree is a free, full-featured Git GUI, with classical point-and-click interface.
  • 🎨 Full graphical representation of repository history and branches.
  • See more at https://www.sourcetreeapp.com/.

🌲 SourceTree Interface

β”Œβ”€ Toolbar ────────────────────────────────────────────────┐
β”‚ [Commit] [Pull] [Push] [Fetch] [Branch] [Merge] [Stash]  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β”Œβ”€ Sidebar ──┐ β”Œβ”€ File Status ─────────────────────────┐ β”‚
β”‚ β”‚ WORKSPACE  β”‚ β”‚ Unstaged files:                       β”‚ β”‚
β”‚ β”‚ β€’ File St..β”‚ β”‚ ☐ src/main.py                         β”‚ β”‚
β”‚ β”‚ β€’ History  β”‚ β”‚ ☐ README.md                           β”‚ β”‚
β”‚ β”‚            β”‚ β”‚                                       β”‚ β”‚
β”‚ β”‚ BRANCHES   β”‚ β”‚ Staged files:                         β”‚ β”‚
β”‚ β”‚ β€’ main     β”‚ β”‚ β˜‘ tests/test_new.py                   β”‚ β”‚
β”‚ β”‚ β€’ feature  β”‚ β”‚                                       β”‚ β”‚
β”‚ β”‚            β”‚ β”‚                                       β”‚ β”‚
β”‚ β”‚ REMOTES    β”‚ β”‚ [Stage All] [Unstage All] [Commit]    β”‚ β”‚
β”‚ β”‚ β€’ origin   β”‚ β”‚                                       β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ β”Œβ”€ Commit Graph ──────────────────────────────────────┐  β”‚
β”‚ β”‚ ● a1b2c3d Fix authentication bug        (main)      β”‚  β”‚
β”‚ β”‚ β”‚                                                   β”‚  β”‚
β”‚ β”‚ ● e4f5g6h Add user registration feature             β”‚  β”‚
β”‚ β”‚ β”œβ”€β— i7j8k9l Update documentation        (feature)   β”‚  β”‚
β”‚ β”‚ β”‚                                                   β”‚  β”‚
β”‚ β”‚ ● m9n0p1q Initial commit                            β”‚  β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
⚠️ **GitHub.com Fallback** ⚠️