Response to Projects Fork REST API contains wrong default branch

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

When using the Projects Fork REST API and the branches parameter to fork a single branch the returned default_branch will contain the "default" default_branch, like main instead of the actual default branch. A subsequent GET API call for that project returns the correct default branch.

Reproduce

# Create the Fork
curl https://gitlab.example.com/api/v4/projects/20/fork -X POST --data '{"source_branch": "to-fork", "name": "source-branch-fork3", "path": "source-branch-fork3"}'
# .default_branch will be "main"
curl https://gitlab.example.com/api/v4/projects/20/<id>
# .default_branch will be "to-fork"
Edited Aug 29, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading