Skip to content

git-co: remove unintentional git pull --all after git switch -c#8

Merged
mlutonsky merged 2 commits intomainfrom
copilot/remove-unintentional-git-pull-after-switch
Mar 14, 2026
Merged

git-co: remove unintentional git pull --all after git switch -c#8
mlutonsky merged 2 commits intomainfrom
copilot/remove-unintentional-git-pull-after-switch

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 14, 2026

git switch -c <branch> origin/<branch> already configures tracking, making the subsequent git pull --all redundant and harmful — it pulls from all configured remotes, not just origin.

Changes

  • git-co: deleted all three git pull --all calls in co():
    • after direct origin/$1 match checkout
    • after single-match auto-checkout
    • after interactive multi-match selection checkout
# Before — unnecessary and overly broad
git switch -c "$1" "origin/$1"
git pull --all   # ← removed

# After
git switch -c "$1" "origin/$1"
Original prompt

git-co: remove unintentional git pull --all after git switch -c

File to modify: git-co

Problem

In the co() function, after tracking a new remote branch with git switch -c "$1" "origin/$1", the script runs git pull --all. This fetches and pulls from all configured remotes, which is almost certainly unintentional — the branch is already set up to track origin/$1 and git switch -c with a start-point does not need a follow-up pull. The same pattern appears in the multi-match interactive section too.

Fix

Remove all occurrences of git pull --all from the file. There are three occurrences:

  1. After git switch -c "$1" "origin/$1" in the direct origin match block (around line 147)
  2. After git switch -c "$branch_name" "origin/$branch_name" in the single-match auto-checkout block (around line 163)
  3. After git switch -c "$branch_name" "origin/$branch_name" in the interactive multi-match selection block (around line 179)

Simply delete those git pull --all lines entirely. No other changes.

The following is the prior conversation context from the user's chat exploration (may be truncated):

Assistant: Here's what you need to enable the Copilot coding agent so I can create pull requests autonomously:


How to Enable the Copilot Coding Agent

The coding agent is what allows me to write code, create branches, and open PRs on your behalf. It requires a supported Copilot plan and then a one-time settings toggle.

Step 1 — Confirm your Copilot plan

The coding agent is available on:

  • GitHub Copilot Pro
  • GitHub Copilot Pro+
  • GitHub Copilot Business
  • GitHub Copilot Enterprise

If you're on the free tier, you'll need to upgrade. You can check or upgrade at github.com/features/copilot/plans.


Step 2 — Enable the agent (personal account)

Since mlutonsky/utils is a personal (user-owned) repository, the coding agent should be available to you automatically once you have a qualifying plan. It is enabled by default for all repositories unless explicitly blocked.

To verify or toggle it:

  1. Go to github.com/settings/copilot
  2. Look for the "Coding agent" section
  3. Make sure it is set to Enabled

Step 3 — Enable GitHub Actions (required for the agent to run)

The coding agent uses GitHub Actions runners to do its work. Make sure Actions are enabled for the repository:

  1. Go to https://github.com/mlutonsky/utils/settings/actions
  2. Under "Actions permissions", select "Allow all actions and reusable workflows" (or at minimum allow GitHub Actions to run)

After enabling

Once those are in place, come back here and ask me to create the pull requests again — I'll be able to autonomously create branches, make all the code changes, and open a PR for each improvement for you to review and merge. See the full docs at Asking GitHub Copilot to create a pull request.

User: I have allowed it, so now please re-create these pull requests automatically

Assistant: All 10 pull requests have been submitted to mlutonsky/utils. Here's a summary of what was created:

# PR Title What it does
1 Add MIT license Adds a LICENSE file so users know they can freely use and adapt the scripts
2 Add ShellCheck CI workflow Adds .github/workflows/shellcheck.yml to automatically lint all shell scripts on every push and PR
3 git-branch-clean: safer branch deletion and fetch error handling Switches git branch -Dgit branch -d and adds an exit guard on git fetch --prune
4 git-co: fix expensive per-branch python3 Levenshtein loop Batches all branch names into a single python3 call instead of spawning one process per branch
5 git-co: remove unnecessary git pull --all Removes the redundant git pull --all after git switch -c, which already sets up tracking
6 git-co: validate branch selection input is numeric Adds [[ "$selection" =~ ^[0-9]+$ ]] guard to prevent a cryptic Bash error on non-numeric input
7 idle-power-manager: add log rotation Adds a rotate_log function and MAX_LOG_LINES env var to cap the log file at 10,000 lines
8 idle-power-manager: fix fragile switch_profile success detection Checks the gdbus call exit code directly instead of grepping stdout for the string "true"
9 idle-power-manager: add DBUS_SESSION_BUS_ADDRESS fallback Exports a fallback socket path so the script works reliably as a systemd user service
10 Add install.sh Adds a one-shot install script that symlinks all scripts to ~/.local/bin/, with README and CLAUDE.md updates

You can review them all at github.com/mlutonsky/utils/pulls and merge whichever you find useful.

User: ...

This pull request was created from Copilot chat.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Co-authored-by: mlutonsky <423848+mlutonsky@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove unintentional git pull after git switch -c git-co: remove unintentional git pull --all after git switch -c Mar 14, 2026
Copilot AI requested a review from mlutonsky March 14, 2026 18:28
@mlutonsky mlutonsky marked this pull request as ready for review March 14, 2026 18:30
Copilot AI review requested due to automatic review settings March 14, 2026 18:30
@mlutonsky mlutonsky merged commit deeeb29 into main Mar 14, 2026
3 checks passed
@mlutonsky mlutonsky deleted the copilot/remove-unintentional-git-pull-after-switch branch March 14, 2026 18:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes redundant and overly broad git pull --all invocations from git-co after creating a local branch that already tracks origin/<branch> via git switch -c.

Changes:

  • Removed git pull --all after direct origin/<branch> creation in co().
  • Removed git pull --all after single-match auto-checkout branch creation.
  • Removed git pull --all after interactive multi-match selection branch creation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants