Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

git: git_create_branch is marked non-destructive but silently resets an existing packed branch

Open Beginner friendly
#5,059 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
git, python
Domain
tooling

Research direction

Start at src/git/src/mcp_server_git/server.py: the git_create_branch handler (around L183-L195) and its annotation block (L396-L404). Reproduce with the issue's pack-refs scratch repo, then add an existing-branch check before repo.create_head so packed refs are refused (or gated behind an explicit force argument), and adjust destructiveHint accordingly. Done when a packed branch is no longer silently moved and the git server's tests pass.

Written by the indexing model from the issue text.

Description

Summary

git_create_branch is annotated destructiveHint: false, but if a branch with the requested name already exists as a packed ref (as after git gc, git pack-refs, or in a fresh clone), the call silently moves that branch to the new base. The previous tip becomes unreachable from every ref, and no reflog entry records the reset. git branch <name> on the CLI would refuse.

Where

Reproduce

  1. In a scratch repo: create main, then a branch feature with one extra commit, and run git pack-refs --all.
  2. Start the git server on that repo.
  3. Call git_create_branch with {"repo_path": "<repo>", "branch_name": "feature", "base_branch": "main"}.
  4. The call reports Created branch 'feature' from 'main'; feature now points at main, its previous commit is unreachable, and git reflog show feature has no entry for the move.

Why it matters

MCP clients relax confirmation for tools that declare destructiveHint: false, so this call can be auto-approved, and it can discard commits.

Possible fix

Check for an existing branch (loose or packed) and return an error, or require an explicit force argument, matching the git CLI. While a force path exists, destructiveHint: true would be accurate.

Found during an audit of MCP tool annotations (AI-assisted source review, then reproduced locally). Happy to send a PR.

Dominant language
JavaScript
Stars
91.2k
Forks
11.8k
Avg merge
6h 52m
Merged PRs (30d)
107

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/servers

All issues in modelcontextprotocol/servers

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.