Unitial icon indicating copy to clipboard operation
Unitial copied to clipboard

gitconfig: improve rbm alias base detection

Open PeterDaveHello opened this issue 2 months ago • 5 comments

User description

Let rbm resolve master/main from local refs first, then fall back to the remote default branch chosen via origin/HEAD (including remote-only refs). Forward all user-supplied arguments to git rebase so the alias mirrors the native command’s behavior.

GitHub Copilot Summary:

This pull request updates the rbm git alias in the gitconfig file to make it more robust and flexible when rebasing onto the main development branch. The new alias now better detects whether the main branch is named master or main, and also supports rebasing onto the corresponding remote branch if the local branch doesn't exist.

Improvements to git alias functionality:

  • Updated the rbm alias to dynamically detect the default branch (master or main) both locally and on the remote, and to fall back to the appropriate remote branch if needed. This makes the alias more reliable in repositories that use different naming conventions for the main branch.

PR Type

Enhancement


Description

  • Improved rbm alias to detect default branch from origin/HEAD first

  • Falls back to local master/main branches if remote default unavailable

  • Supports remote-only branches when local equivalents don't exist

  • Forwards all user arguments to git rebase command


Diagram Walkthrough

flowchart LR
  A["origin/HEAD<br/>symbolic ref"] -->|Extract remote branch| B["Check if master/main"]
  B -->|Found locally| C["Use local branch"]
  B -->|Not found locally| D["Use remote branch"]
  D -->|Still not found| E["Fallback to<br/>master/main"]
  E -->|Not found| F["Error"]
  C --> G["git rebase<br/>with all args"]
  D --> G

File Walkthrough

Relevant files
Enhancement
gitconfig
Improve rbm alias branch detection logic                                 

gitconfig

  • Enhanced rbm alias to resolve default branch from origin/HEAD symbolic
    reference first
  • Added fallback logic to check local master/main branches if remote
    default unavailable
  • Implemented support for remote-only branches when local equivalents
    don't exist
  • Changed argument passing from single positional argument to all
    user-supplied arguments via "$@"
+1/-1     

Summary by CodeRabbit

  • Chores
    • Enhanced the rbm Git alias for improved base branch detection. Now intelligently derives the base branch from remote origin HEAD with fallback logic to master or main branches, providing more robust handling of edge cases and remote branch naming.

PeterDaveHello avatar Nov 07 '25 15:11 PeterDaveHello