terminal keyboard, software code

Photo by Nemuel Sereti on Pexels


Pull requests shouldn’t read like a crime scene investigation, and your CI/CD pipeline shouldn’t require a sacrificed goat to pass. Today, we are ditching the over-engineered enterprise bloat and diving straight into the lean, mean, terminal-driven GitHub workflows that will save your sanity and keep your team off your back.

Welcome back to the Old Lane 17 workshop. If your git history looks like a thriller novel written by someone having a panic attack, you are in the right place. Let’s fix that.

The Art of the Pull Request That People Actually Want to Read

Nobody wants to review a pull request containing 4,000 lines of modified code spanning 47 unrelated files with the commit message “fix stuff.” If you submit that, your coworkers will quietly judge you behind their webcams.

Instead, treat your PR like a love letter to the poor soul who has to review it. Keep it scoped, keep it focused, and use the GitHub CLI (gh) to open it straight from your terminal without ever touching a browser tab.

bash
# Create your feature branch like an adult
git checkout -b feature/user-profile-avatar

# Do some brilliant coding, then commit with intention
git add .
git commit -m "feat(auth): add user avatar upload endpoint"

# Push to origin
git push -u origin feature/user-profile-avatar

# Open the PR via CLI without leaving the comfort of your dark-mode terminal
gh pr create --title "Add user avatar upload endpoint" --body "Closes #42. Adds a shiny new endpoint for uploading avatars and handles malicious SVG uploads gracefully."

The “Oh Crap” Scenario: Fixing the Accidental Main Branch Commit

We have all been there. It is 4:50 PM on a Friday. You are tired, hopped up on cold brew, and you accidentally commit a half-baked feature directly to main instead of your feature branch. Cue the cold sweat.

Don’t panic and definitely don’t delete your repository. Here is the cleanest way to fix your mistake using Git’s built-in time machine:

bash
# 1. Create a safe branch from your current messy state
git branch emergency-fix

# 2. Hard reset your local main branch back to the remote origin state
git reset --hard origin/main

# 3. Switch back to your safe branch and keep working properly
git checkout emergency-fix

Just like that, main is pristine, your work is saved, and nobody has to know you almost ruined the weekend deployment.

Automating the Boring Stuff with GitHub Actions CI

Stop running tests manually like it’s 2012. You need a basic CI pipeline that runs your test suite every time code goes up, acting as an automated bodyguard against silly mistakes (like syntax errors in Python scripts you pushed before testing).

Create a file at .github/workflows/ci.yml in your repository:

yaml
name: CI Pipeline

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

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        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 pytest

      - name: Run test suite
        run: |
          pytest

Commit this, push it up, and watch GitHub happily run your tests in the cloud.

Enforcing Adult Supervision with Branch Protection

Finally, do yourself a favor and lock down your main branch. Go to your repository settings on GitHub, navigate to Branches, and add a rule for main.

Require at least one approving review, demand that status checks (like the CI workflow we just wrote) pass before merging, and check the box that forces linear history. This simple move protects the codebase from your 2 AM self and keeps the team standards high with zero awkward conversations required.


Published by the Old Lane Developer Desk.

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