checkout

Function checkout 

Source
pub async fn checkout(repo: RepoHandle, opts: CheckoutOpts) -> GitResult<()>
Expand description

Execute checkout operation with the given options.

This performs a complete Git checkout operation:

  1. Resolves the reference to a commit
  2. Extracts the tree from the commit
  3. Updates the working directory files
  4. Updates the index
  5. Updates HEAD (symbolic for branches, direct for commits/tags)

§Symbolic vs Detached HEAD

  • Local branches (e.g., “main”, “refs/heads/feature”) → Symbolic HEAD
  • Remote branches (e.g., “origin/main”) → Detached HEAD
  • Tags (e.g., “v1.0”, “refs/tags/v1.0”) → Detached HEAD
  • Commit SHAs (e.g., “abc123”) → Detached HEAD