Skip to content

(bug): -b/--branch flag clones default branch instead of specified branch #574

@yoonsoo-park

Description

@yoonsoo-park

Description

When using the -b/--branch flag with a private GitHub repository, gitingest clones and checks out the default branch (e.g., release) instead of the specified branch. The output contains the default branch's files, not the target branch's files.

Steps to Reproduce

# Clone a specific feature branch from a private repo
gitingest -b my-feature-branch \
  -t "$GITHUB_TOKEN" \
  -o /tmp/output.txt \
  https://github.com/org/repo

Expected Behavior

The output should contain the file tree and contents from my-feature-branch.

Actual Behavior

The output contains the file tree and contents from the default branch (release).

Looking at the logs, gitingest runs:

git clone --single-branch --no-checkout --depth=1 <url> <local-path>

Then checks out a commit that belongs to the default branch, not the specified branch:

Checking out commit | {"commit":"11c94773..."}   # ← this is the default branch HEAD

The actual branch tip is a different SHA (6a44be78... per GitHub API).

Verification

I verified this is a gitingest issue, not a repo issue:

# GitHub API confirms the branch exists and has different content
gh api repos/org/repo/branches/my-feature-branch --jq '.commit.sha'
# Returns: 6a44be78...  (different from what gitingest checked out)

# GitHub compare shows 120 commits ahead with 285 changed files
gh api repos/org/repo/compare/release...my-feature-branch --jq '.ahead_by'
# Returns: 120

Scope

Tested with 4 different branches on the same private repo — all 4 produced byte-identical output matching the default branch. This is not branch-specific.

Environment

  • gitingest: 0.3.1 (latest)
  • Python: 3.13
  • OS: macOS (Darwin 25.4.0)
  • Auth: GitHub PAT via -t flag
  • Repo: Private GitHub repository with non-main default branch (release)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions