fix(repo create): clone instead of git init when --readme is used

Summary

  • When --readme is passed, GitLab initializes the repository server-side with a commit on its default branch (e.g. main on GitLab.com). Previously the command ran git init locally, leaving the local repo on a different branch (typically master) than the remote before any work was done.
  • Now when --readme is used and the directory isn't already a git repo, the repository is cloned after creation so the local branch always matches the remote.
  • Updates flag descriptions for --defaultBranch, --readme, and --skipGitInit to accurately reflect their behavior.

Test plan

  • glab repo create --readme in an empty directory — local branch should match GitLab default
  • glab repo create --readme --defaultBranch develop — both local and remote should be on develop
  • glab repo create (no --readme) — existing behavior unchanged, GitLab adopts first pushed branch
  • glab repo create --readme in an already-initialized git directory — remote is added, no clone attempted
  • Unit tests pass: go test ./internal/commands/project/create/...

Closes #7847 (closed)

Edited by Kai Armstrong

Merge request reports

Loading