Connect GitHub to Claude and check which branch files it actually read

Use Claude's built-in GitHub integration when you want selected repository files as context in a chat or project. Choose the intended repository, branch and files, then ask for a source-based answer. If a repository changes after you added it to project knowledge, sync the selected material before trusting an answer about the new code.

This route differs from a GitHub plugin in Claude Code. Anthropic's built-in integration documentation, checked October 24, 2026, describes syncing file names and contents on a specific branch, without commit history or pull-request metadata. The GitHub plugin provides a separate Claude Code workflow with repository-management actions. Choose the route that supplies the evidence your question needs.

Add the smallest useful repository scope

In a chat, open + > Add from GitHub and select files or folders. In a project, use the + in project knowledge, choose GitHub, then select the repository and relevant files. Complete GitHub authorization if prompted. Follow your organization's access policy for private code. Official setup

For a code question, include the implementation, relevant caller and test. A single function can omit the caller's default or the test's expected boundary. Selecting an entire unrelated monorepo can bury the few files that decide the answer.

Use a known boundary to check the context

In this authored example, a repository's main branch has:

# booking/rules.py
MAX_GUESTS = 24

def permits_guest_count(count):
    return 1 <= count <= MAX_GUESTS

A proposed room-expansion branch instead sets MAX_GUESTS = 30. Those are fictional teaching branches. They make the source selection observable: 25 guests are rejected under the shown main rule but accepted under the proposed rule.

Before asking for an onboarding explanation, ask Claude to identify the selected file and quote the constant and comparison. Then compare those lines with the same branch in GitHub. An answer of “30 guests are permitted” is insufficient unless the intended branch actually contains that rule.

Use the repository files I added through GitHub.
Expected repository and branch: [OWNER/REPO, BRANCH]
Relevant implementation, caller and tests: [PATHS]

Read only. Identify the source files you can actually inspect.
Quote the guest limit and the comparison that applies it. Explain
the results for counts0,1,24,25 under the supplied implementation.
Do not substitute another branch or infer an unprovided proposal.
If branch identity cannot be established from the available context,
say what I need to verify in GitHub. Do not invent a commit hash.
Do not edit files, create issues, open pull requests or change access.

For the shown main fixture, the expected results are false, true, true and false. If the returned code says 30, investigate the source selection before polishing the explanation. If it says 24 but returns true for 25, the interpretation itself is wrong.

Sync changes and repeat the same question

For project knowledge, Anthropic documents Sync now to fetch changes to previously selected files and folders, and Configure files to change that selection. A new relevant file may require reviewing the configured scope. Sync behavior

After syncing, begin a fresh focused request for the current lines and boundary results. Preserve an earlier explanation as an older interpretation rather than assuming every prior message rewrites itself. If you need to know who approved the expansion or what a pull-request discussion decided, obtain that history through a route that actually provides it; file contents alone cannot establish approval.

For GitHub Actions dependency behavior, the evidence is workflow YAML and actual job conclusions. For Claude local desktop tools, the evidence includes an installed server's tool availability. This task establishes the selected branch-file context before either kind of analysis.

Keep the checked explanation with its repository, branch, file paths and review date. Before another teammate relies on the guest rule, have them open the maintained source and confirm that the documented boundary still matches it.

Keep reading