terminal keyboard, software code

Photo by Rafael Minguet Delgado on Pexels


We’ve all been there: it’s 4:58 PM on a Friday, you’ve just pushed a brilliant fix, and your pull request consists of a single cryptic commit message titled “fix stuff pls.” Your reviewer opens it, sighs audibly across the timezone, and leaves twelve comments demanding context. Let’s fix that forever with a clean, terminal-first GitHub workflow that respects your time and your teammates’ sanity.

Welcome back to the Old Lane 17 engineering blog, where we like our code clean, our coffee strong, and our Git workflows free of over-engineered enterprise bloat. Today, we are looking at how to graduate from the GitHub web interface GUI-clickers and adopt a lightning-fast, terminal-driven review culture using the official GitHub CLI (gh).


1. Ditch the Browser: Meet the gh CLI

Why alt-tab to a browser, navigate to a tab, click “New Pull Request,” and fill out a form when you can do it all while keeping your hands glued to your mechanical keyboard?

First, install the GitHub CLI if you haven’t already. If you’re on macOS:

bash
brew install gh

Then, authenticate your terminal with GitHub once and forget it exists:

bash
gh auth login

Follow the interactive prompts, and you are ready to command GitHub straight from your beloved terminal.


2. Writing Elite Pull Requests (That People Actually Want to Read)

An elite pull request doesn’t require a novel. It requires context, scope, and a clear path to testing. Instead of writing a vague summary, let’s script our PR creation using gh with a robust template.

When you push your feature branch, open a PR instantly from the terminal like this:

bash
git checkout -b feature/auth-fix
# Do some legendary coding...
git add .
git commit -m "fix: resolve token expiration edge case in auth middleware"
git push origin feature/auth-fix

# Now, open the PR without touching a browser tab
gh pr create --title "Fix token expiration edge case" --body "## Summary
- Prevents infinite redirect loops when JWT expires.
- Adds unit tests for edge-case timestamps.

## Test Plan
- Run \`pytest tests/test_auth.py\` to verify."

Boom. Done. Your reviewer gets immediate context, a test plan, and a clear reason why the code exists.


3. The Classic Gotcha: The “Merge Conflict” Dread

The Scenario: You spent three hours perfecting your branch, only to find out someone merged a change to main five minutes ago. GitHub now displays that terrifying yellow banner: This branch has conflicts that must be resolved.

Panicking and clicking the web editor “Resolve Conflicts” button is a rite of passage, but it’s also a great way to accidentally delete your coworker’s production fix. Let’s handle it cleanly in the terminal.

First, fetch and rebase against main:

bash
git fetch origin
git checkout feature/auth-fix
git rebase origin/main

Git will politely pause and tell you which files are conflicted. Open your favorite editor (VS Code, Neovim, or whatever pays the bills), clean up the <<<<<<< HEAD markers, save the file, and continue the rebase:

bash
git add conflicted_file.py
git rebase --continue

Now, force-push your clean, conflict-free branch back up. Because you are updating your own feature branch, this is safe and keeps history linear:

bash
git push origin feature/auth-fix --force-with-lease

(Pro-tip: Always use --force-with-lease instead of --force. It’s the polite way of saying “overwrite my remote branch unless someone else pushed to it in the meantime.”)


4. Automating Reviews and Merging

Once your CI checks pass (which we’ll cover in a future guide), you can review status, read comments, and merge directly from your shell. No mouse required.

Check the status of your open PRs:

bash
gh pr status

Ready to merge? Squash and merge it cleanly, deleting the remote branch automatically so your repo stays pristine:

bash
gh pr merge --squash --delete-branch

And just like that, you are back to writing code instead of wrestling with browser windows. Stay tuned for our next session, where we automate this entire dance with a lightweight GitHub Actions workflow. Happy coding!


Published by the Old Lane Developer Desk.

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