Introduction
This guide provides a structured approach to setting up Git, GitHub, Homebrew (for macOS), and Chocolatey (for Windows). It also covers the installation of essential tools like Amazon Q, Arc Browser, and Warp Terminal. Whether you're a beginner or an experienced developer, follow this guide step by step to configure your development environment efficiently.
1. GitHub CLI (gh
) and Authentication
The gh
command-line tool allows you to interact with GitHub directly from your terminal. It simplifies repo management, pull requests, issues, and CI/CD workflows.
Authenticate GitHub CLI
gh auth login
Once configured, you can see your Git global settings:
git config --list --global
To remove GitHub authentication data:
gh auth logout -h github.com
rm ~/.git-credentials
rm -rf ~/.ssh/
rm ~/.gitconfig
echo "url=https://github.com" | git credential reject
rm -rf ~/.config/gh
Running echo "url=https://github.com" | git credential reject
may not work on all systems. In that case, run the following command:
git credential reject https://github.com
2. Initializing a Git Repository
Git Initialization (git init
)
git init
ls -la # Lists all files including hidden ones
ls -la .git # View the .git directory
Understanding the .git
Folder
- HEAD: Points to the current branch.
- config: Stores repository settings.
- refs/: Contains references to commits (branches and tags).
- objects/: Stores commit objects.
- hooks/: Scripts that trigger on Git events.
To view details inside .git
, run:
cat .git/HEAD
cat .git/config
ls -la .git/refs/heads/ # See available branches
ls -la .git/objects/
3. Tracking Changes with Git
Adding Files to Staging
git add <file_name>
Committing Changes
git commit -m "Added new file"
Pushing Changes to GitHub
git push origin main
Undoing Commits
Undo the last commit (keep changes unstaged):
git reset --soft HEAD~1
Undo the last commit (discard changes):
git reset --hard HEAD~1
Resolving Merge Conflicts
git status # Check conflicts
nano <conflicted_file> # Edit the file to resolve conflicts
git add <conflicted_file>
git commit -m "Resolved merge conflict"
4. Git Configuration and Credential Management
Checking Local & Global Git Configuration
git config --list --local # Show local repository settings
git config --global --list # Show global settings
Storing Credentials
macOS:
git config --global credential.helper osxkeychain
Linux:
git config --global credential.helper cache
Changing Default Editor
Use Nano:
git config --global core.editor nano
Use VS Code:
git config --global core.editor "code --wait"
5. Installing Homebrew (macOS)
Homebrew is a package manager for macOS that simplifies software installation.
Installing Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Useful Homebrew Commands
brew search <package>
brew info <package>
brew install <package>
brew update
brew upgrade
brew list
brew uninstall <package>
brew cleanup # Remove old versions and free space
6. Installing Chocolatey (Windows)
Chocolatey is a package manager for Windows that simplifies software installation.
Installing Chocolatey
Run PowerShell as Administrator and execute:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Verifying Installation
choco -?
7. Installing Essential Development Tools
Installing Git
macOS:
brew install git
Windows:
choco install git -y
Installing VS Code
macOS:
brew install --cask visual-studio-code
Windows:
choco install vscode -y
Installing Amazon Q
macOS:
brew install --cask amazon-q
Windows:
First, check if amazon-q
exists in Chocolatey by running:
choco search amazon-q
- If it exists, install it with:
choco install amazon-q -y
- If it doesn't exist, try installing it manually via the command line.
Installing Warp Terminal
macOS:
brew install --cask warp
Windows:
choco install warp -y
Installing Arc Browser
macOS:
brew search arc
brew install --cask arc
Windows:
choco search arc
If unavailable, download manually from Arc Browser.
8. Working in GitHub Codespaces
- Open your repository in GitHub.
- Click Code > Codespaces.
- Click Continue Working in GitHub Codespace.
- Select an instance type based on your project needs:
- Basic: Suitable for lightweight projects.
- Standard: Recommended for most web and mobile development.
- Performance: For complex builds or heavy computation.
9. GitHub SSH Key Setup
Generate a New SSH Key
ssh-keygen -t ed25519 -C "your_email@example.com"
Add SSH Key to GitHub
cat ~/.ssh/id_ed25519.pub # Copy the key content
Then add it to GitHub > Settings > SSH Keys.
Test SSH Connection
ssh -T git@github.com
You're right! Let me break it down clearly and explain how it works step by step.
10. Bonus: Configure Terminal for Quick Search and URL Opening
Wouldn’t it be great if you could open websites or search Google directly from the terminal using a simple command like:
oh "github.com"
(Opens https://github.com
in your browser)
or
oh "how to install python"
(Searches Google for "how to install python")
Let’s set it up!
📌 Step 1: Check Your Default Shell
Before adding the function, confirm whether you are using Zsh or Bash by running:
echo $SHELL # or echo $0
- If the output contains zsh (e.g.,
/bin/zsh
), you will edit~/.zshrc
. - If the output contains bash (e.g.,
/bin/bash
), you will edit~/.bashrc
.
🔹 macOS default shell is Zsh (since macOS Catalina).
🔹 Linux may use Bash or Zsh, depending on the distribution.
🔹 Window uses Bash from Git Bash.
📌 Step 2: Open the Configuration File
- If using Zsh (macOS default), open the Zsh configuration file:
nano ~/.zshrc
- If using Bash (common on Linux), open the Bash configuration file:
nano ~/.bashrc
📌 Step 3: Add the oh
Function
Paste the following Mac-compatible function in ~/.zshrc
or ~/.bashrc
(for Bash users).
For macOS (Uses open
)
oh() {
local input="$*"
# Ensure input is a single word with a dot (like a real domain)
if [[ "$input" =~ ^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ && ! "$input" =~ \ ]]; then
open "https://$input"
else
open "https://www.google.com/search?q=$(echo "$input" | tr ' ' '+')"
fi
}
For Linux (Uses xdg-open
)
On Linux, replace open
with xdg-open
:
oh() {
local input="$*"
# Ensure input is a single word with a dot (like a domain), and doesn't contain spaces
if [[ "$input" =~ ^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ && ! "$input" =~ [[:space:]] ]]; then
xdg-open "https://$input"
else
xdg-open "https://www.google.com/search?q=$(echo "$input" | tr ' ' '+')"
fi
}
For Windows (Uses start
)
On Windows, replace open
or xdg-open
with start
:
oh() {
local input="$*"
# Ensure input is a valid domain (contains a dot and no spaces)
if [[ "$input" =~ ^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ && ! "$input" =~ [[:space:]] ]]; then
powershell -c "Start-Process 'https://$input'"
else
powershell -c "Start-Process 'https://www.google.com/search?q=$(echo "$input" | tr ' ' '+')'"
fi
}
Cross-Platform Version (Auto-Detects OS)
If you want a single function that works on both macOS, Linux, and windows, use:
oh() {
local input="$*"
local open_cmd
# Detect OS and set the correct open command
case "$(uname)" in
Darwin*) open_cmd="open" ;;
Linux*) open_cmd="xdg-open" ;; # Linux (xdg-open should use an existing tab when possible)
CYGWIN*|MINGW*|MSYS*) open_cmd="powershell -c start" ;;
*) echo "Unsupported OS" && return 1 ;;
esac
# Open URL or search Google
if [[ "$input" =~ ^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then
$open_cmd "https://$input"
else
$open_cmd "https://www.google.com/search?q=$(echo "$input" | tr ' ' '+')"
fi
}
📌 Step 4: Save and Apply the Changes
-
Press
CTRL + X
to exit. -
Press
Y
to confirm saving. -
Press
ENTER
to overwrite the file.
Then, apply the changes by running:
source ~/.zshrc # If using Zsh
source ~/.bashrc # If using Bash
🚀 Step 5: Try It Out!
✅ Open a Website:
oh github.com
(Opens https://github.com
in your browser.)
✅ Perform a Google Search:
oh "best terminal commands for Mac"
(Opens Google search: https://www.google.com/search?q=best+terminal+commands+for+Mac
)
✅ Open Any Website Without Typing https://
oh openai.com
(Opens https://openai.com
.)
🔍 How It Works
-
Detects if the input is a domain using regex (
^[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
). - If yes, it adds
https://
and opens the website. If no, it converts spaces to
+
and performs a Google search.Uses
open
on macOS andxdg-open
on Linux, ensuring cross-platform compatibility.
🔄 Troubleshooting
🔹 Browser doesn’t open?
- Ensure
open
(Mac) orxdg-open
(Linux) is available. - On Linux, install
xdg-utils
if missing:
sudo apt install xdg-utils # Debian/Ubuntu
sudo dnf install xdg-utils # Fedora
✅ Get all setup guides & commands here 👉 Primary Dev Setup 🚀
Top comments (0)