terminal keyboard, software code, coding screen

Photo by Bibek ghosh on Pexels


We’ve all been there: staring at the GitHub web interface at 2 AM, clicking “Compare & pull request” like a digital slot machine, and praying the CI pipeline doesn’t burst into flames. It’s time to ditch the mouse-heavy ritual, embrace the raw power of the GitHub CLI, and write pull requests that don’t make your senior reviewer want to weep.

Welcome back to Old Lane 17, where we prefer our coffee black, our terminal windows transparent, and our engineering workflows free of enterprise bloat. Today, we are looking at how to turn your GitHub routine from a frantic browser-tab circus into a smooth, keyboard-driven masterpiece.

The CLI is Your New Best Friend

If you are still opening a browser to create a pull request, please take a deep breath, close your browser tabs, and install gh. The GitHub CLI is the official tool that lets you interact with GitHub right from the comfort of your shell. No context switching, no mouse fatigue.

First, let’s get it installed and authenticate. If you’re on macOS or Linux, it’s a quick package-manager affair:

bash
# macOS via Homebrew
brew install gh

# Ubuntu/Debian via official keyring
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/source.list.d/github-cli.list > /dev/null
sudo update-apt
sudo apt install gh

# Authenticate with your GitHub account
gh auth login

Follow the prompts, pick HTTPS or SSH (SSH if you prefer not typing passwords like it’s 1999), and you’re ready to roll.

Writing Elite Pull Requests (Without the Drama)

Writing a good PR description shouldn’t feel like drafting a legal thesis. But dumping fixes stuff into the title box is a fast pass to getting ignored in code review.

With the GitHub CLI, you can push your branch and open a PR in one fluid motion, complete with a clean template:

bash
# Push your local branch to origin
git push -u origin feature/auth-bypass-fix

# Open a pull request right from your terminal
gh pr create --title "fix: Prevent auth token leak on retry" --body "## Summary
- Sanitizes headers before retrying failed auth requests.
- Adds regression test suite to cover the edge case.

## Test Plan
- Run \`pytest tests/test_auth.py\` locally and verify all green."

Boom. Done. You didn’t have to touch a trackpad once.

The Gotcha: The Detached HEAD and Ghost Merges

The Scenario: You finish a feature, merge it via command line, but forget to clean up your local branches. Three weeks later, you run git checkout main, try to pull, and your terminal explodes with conflicting local references and a ghost commit from a branch you deleted on GitHub yesterday.

The Fix: Keep your local environment pristine by pruning remote tracking branches and setting up an automated habit. Run this ritualistic cleanup command whenever your workspace feels cluttered:

bash
# Prune deleted remote branches and sync up
git fetch --prune

# Delete local branches that have already been merged
git branch --merged | egrep -v "(^\*|main|master|dev)" | xargs git branch -d

If it’s already merged into main, let it go. Your local machine is an apartment, not a storage unit.

Setting Up Basic CI with GitHub Actions

Don’t let “CI/CD” intimidate you into buying a $5,000 enterprise pipeline configuration book. Continuous Integration just means “run my tests automatically so I don’t merge broken code.”

Create a simple workflow file in your repository. GitHub reads anything inside .github/workflows/ as a command to execute.

bash
# Create the workflows directory
mkdir -p .github/workflows

Now, create a file named .github/workflows/ci.yml using your favorite terminal text editor (we won’t judge if it’s Vim, Nano, or Micro):

yaml
name: CI

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'
          
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          
      - name: Run tests
        run: |
          pytest

Commit that file, push it up, and watch GitHub Actions run your test suite automatically on every pull request. If the tests fail, the merge button stays locked. Democracy and code quality, preserved.

Happy coding, stay off the web browser, and keep your terminal clean.


Published by the Old Lane Developer Desk.

Disclaimer: This article was generated and formatted with the assistance of Artificial Intelligence.