class documentation
Working tree operations for a Git repository.
This class provides methods for working with the working tree, such as staging files, committing changes, and resetting the index.
| Method | __init__ |
Initialize a WorkTree for the given repository. |
| Method | commit |
Create a new commit. |
| Method | configure |
Ensure the repository is configured for cone-mode sparse-checkout. |
| Method | get |
Return a list of sparse-checkout patterns from info/sparse-checkout. |
| Method | infer |
Return True if 'core.sparseCheckoutCone' is set to 'true' in config, else False. |
| Method | reset |
Reset the index back to a specific tree. |
| Method | set |
Write the given cone-mode directory patterns into info/sparse-checkout. |
| Method | set |
Write the given sparse-checkout patterns into info/sparse-checkout. |
| Method | stage |
Stage a set of paths. |
| Method | unstage |
Unstage specific file in the index. |
| Instance Variable | path |
Undocumented |
| Method | _sparse |
Return the path of the sparse-checkout file in this repo's control dir. |
| Instance Variable | _repo |
Undocumented |
Initialize a WorkTree for the given repository.
| Parameters | |
repo:Repo | The repository this working tree belongs to |
path:str | bytes | os.PathLike[ | Path to the working tree directory |
def commit(self, message: b'HEAD'), merge_heads:
str | bytes | Callable[ [ Any, Commit], bytes] | None = None, committer: bytes | None = None, author: bytes | None = None, commit_timestamp: float | None = None, commit_timezone: int | None = None, author_timestamp: float | None = None, author_timezone: int | None = None, tree: ObjectID | None = None, encoding: bytes | None = None, ref: Ref | None = Ref(Sequence[ ObjectID] | None = None, no_verify: bool = False, sign: bool | None = None, signoff: bool | None = None) -> ObjectID:
¶
Create a new commit.
If not specified, committer and author default to get_user_identity(..., 'COMMITTER') and get_user_identity(..., 'AUTHOR') respectively.
| Parameters | |
message:str | bytes | Callable[ | Commit message (bytes or callable that takes (repo, commit) and returns bytes) |
committer:bytes | None | Committer fullname |
author:bytes | None | Author fullname |
commitfloat | None | Commit timestamp (defaults to now) |
commitint | None | Commit timestamp timezone (defaults to GMT) |
authorfloat | None | Author timestamp (defaults to commit timestamp) |
authorint | None | Author timestamp timezone (defaults to commit timestamp timezone) |
tree:ObjectID | None | SHA1 of the tree root to use (if not specified the current index will be committed). |
encoding:bytes | None | Encoding |
ref:Ref | None | Optional ref to commit to (defaults to current branch). If None, creates a dangling commit without updating any ref. |
mergeSequence[ | Merge heads (defaults to .git/MERGE_HEAD) |
nobool | Skip pre-commit and commit-msg hooks |
sign:bool | None | GPG Sign the commit (bool, defaults to False, pass True to use default GPG key, pass a str containing Key ID to use a specific GPG key) |
signoff:bool | None | Add Signed-off-by line (DCO) to commit message. If None, uses format.signoff config. |
| Returns | |
ObjectID | New commit SHA1 |
Write the given cone-mode directory patterns into info/sparse-checkout.
For each directory to include, add an inclusion line that "undoes" the prior !/*/ 'exclude' that re-includes that directory and everything under it. Never add the same line twice.
def stage(self, fs_paths:
str | bytes | os.PathLike[ str] | Iterable[ str | bytes | os.PathLike[ str]]):
¶
Stage a set of paths.
| Parameters | |
fsstr | bytes | os.PathLike[ | List of paths, relative to the repository path |