Set HEAD to point to the given target. Parameters: target The new target for HEAD. Can be a string or Oid (to detach).
(self, target: Oid | str)
| 514 | # Setting HEAD |
| 515 | # |
| 516 | def set_head(self, target: Oid | str) -> None: |
| 517 | """ |
| 518 | Set HEAD to point to the given target. |
| 519 | |
| 520 | Parameters: |
| 521 | |
| 522 | target |
| 523 | The new target for HEAD. Can be a string or Oid (to detach). |
| 524 | """ |
| 525 | |
| 526 | if isinstance(target, Oid): |
| 527 | oid = ffi.new('git_oid *') |
| 528 | ffi.buffer(oid)[:] = target.raw[:] |
| 529 | err = C.git_repository_set_head_detached(self._repo, oid) |
| 530 | check_error(err) |
| 531 | return |
| 532 | |
| 533 | # if it's a string, then it's a reference name |
| 534 | err = C.git_repository_set_head(self._repo, to_bytes(target)) |
| 535 | check_error(err) |
| 536 | |
| 537 | # |
| 538 | # Diff |