Skip to content

Improve branch renaming UX on Windows (Case-only changes require double rename) #21320

Closed

Description

@hi2242

I'm opening this issue to bring attention to a specific usability hurdle regarding branch renaming on Windows, which I previously mentioned in a comment here: #21287 (comment).

I understand that you are not actively looking for external contributions for this feature at the moment. However, I have already investigated the codebase and identified a clean, low-risk solution that I would love to implement if permitted.

Proposed Solution

I found that the logic can be handled within app/src/lib/git/branch.ts inside the renameBranch function.
Since Windows is case-insensitive, we can detect if the OS is win32 and if the rename is only a case change. In that specific scenario, we can implement a two-step rename process (e.g. oldName -> tempName -> newName) to force the filesystem to register the change.

Here is the rough implementation idea:

Click to view the code snippet
export async function renameBranch(repository: Repository, branch: Branch, newName: string): Promise<void> {
  const oldName = branch.nameWithoutRemote
  const isCaseInsensitiveRename = oldName.toLowerCase() === newName.toLowerCase() && oldName !== newName
  const isWindows = process.platform === 'win32'

  // If Windows and case-only rename, use the two-step rename process
  if (isWindows && isCaseInsensitiveRename) {
    const tempName = `${oldName}-temp-${Date.now()}`
    
    // Step 1: Rename to temp name
    await git(['branch', '-m', oldName, tempName], repository.path, 'renameBranch-step1')
    
    // Step 2: Rename to target name
    await git(['branch', '-m', tempName, newName], repository.path, 'renameBranch-step2')
    
    return
  }

  // Default behavior for other cases
  await git(['branch', '-m', oldName, newName], repository.path, 'renameBranch')
}

This approach isolates the fix to the Git operation layer without requiring complex UI changes.

Since I have a clear implementation plan ready that aligns with the project's architecture, would you be open to adding the help-wanted label to this issue? I am eager to submit a PR following your contribution guidelines to help improve the Windows user experience.

Activity

  1. added
    triage
    on Nov 28, 2025
  2. github-actions commented on Nov 28, 2025

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as a feature request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Issues marked as ideal for external contributors label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  3. removed
    triage
    on Nov 28, 2025
  4. niik commented on Nov 28, 2025

    @niik
    Member

    This is an issue on macOS (on the default file system at least) as well. You wouldn't even need to do the temp branch name, you could just pass -M instead of -m to force the change. The problem is knowing for certain that the file system is case insensitive at the location.

    Like, on Windows (NTFS) you can set a folder to be case sensitive. To be super certain we're not overwriting a branch that differs we'd have to check that they point to the same object as well.

  5. niik commented on Nov 28, 2025

    @niik
    Member

    Opened #21323 to address this

  6. hi2242 commented on Nov 28, 2025

    @hi2242
    ContributorAuthor

    @niik

    Thanks for the quick response and the fix! I see that using the -M flag is a much cleaner approach than what I proposed.

    As a frequent user of GitHub Desktop, I was really hoping to have the honor of contributing to the codebase myself, but I'm just glad this UX hurdle is being resolved so fast. I will definitely look for other opportunities to contribute in the future!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions