or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

command.mdconfiguration.mddatabase.mddiff.mdexceptions.mdindex-staging.mdindex.mdobjects.mdreferences.mdremote.mdrepository.md

command.mddocs/

0

# Command Interface

1

2

Direct access to Git command-line operations with comprehensive error handling, output parsing, and environment control. Enables custom Git operations not covered by high-level interfaces.

3

4

## Capabilities

5

6

```python { .api }

7

class Git:

8

def __init__(self, working_dir: PathLike = None):

9

"""Initialize Git command interface."""

10

11

def execute(self, command: list, istream: BinaryIO = None, with_extended_output: bool = False, with_exceptions: bool = True, as_process: bool = False, output_stream: BinaryIO = None, stdout_as_string: bool = True, kill_after_timeout: int = None, with_stdout: bool = True, universal_newlines: bool = False, shell: bool = None, env: dict = None, max_chunk_size: int = None, **subprocess_kwargs) -> Union[str, tuple]:

12

"""Execute git command."""

13

14

def __getattr__(self, name: str) -> Callable:

15

"""Dynamic git command creation (e.g., git.status(), git.log())."""

16

17

@property

18

def working_dir(self) -> str:

19

"""Working directory for git commands."""

20

21

@classmethod

22

def refresh(cls, path: PathLike = None) -> bool:

23

"""Refresh git executable path."""

24

25

class GitMeta(type):

26

"""Metaclass for Git command interface."""

27

```

28

29

## Usage Examples

30

31

```python

32

from git import Git

33

34

# Create Git command interface

35

git = Git('/path/to/repo')

36

37

# Execute git commands

38

status_output = git.status('--porcelain')

39

log_output = git.log('--oneline', '-10')

40

41

# With custom options

42

result = git.execute(['rev-parse', 'HEAD'], with_extended_output=True)

43

stdout, stderr = result[:2]

44

45

# Custom environment

46

custom_env = {'GIT_AUTHOR_NAME': 'Custom Author'}

47

commit_output = git.commit('-m', 'Custom commit', env=custom_env)

48

49

# Stream processing

50

with open('output.txt', 'wb') as f:

51

git.log('--stat', output_stream=f)

52

```