@@ -350,6 +350,7 @@ def __setstate__(self, d: Dict[str, Any]) -> None:
350
350
for, which is not possible under most circumstances.
351
351
352
352
See:
353
+
353
354
- :meth:`Git.execute` (on the ``shell`` parameter).
354
355
- https://github.com/gitpython-developers/GitPython/commit/0d9390866f9ce42870d3116094cd49e0019a970a
355
356
- https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags
@@ -361,15 +362,50 @@ def __setstate__(self, d: Dict[str, Any]) -> None:
361
362
GIT_PYTHON_GIT_EXECUTABLE = None
362
363
"""Provide the full path to the git executable. Otherwise it assumes git is in the path.
363
364
364
- Note that the git executable is actually found during the refresh step in
365
- the top level ``__init__``.
365
+ :note: The git executable is actually found during the refresh step in
366
+ the top level :mod:`__init__`. It can also be changed by explicitly calling
367
+ :func:`git.refresh`.
366
368
"""
367
369
368
370
_refresh_token = object () # Since None would match an initial _version_info_token.
369
371
370
372
@classmethod
371
373
def refresh (cls , path : Union [None , PathLike ] = None ) -> bool :
372
- """This gets called by the refresh function (see the top level __init__)."""
374
+ """This gets called by the refresh function (see the top level __init__).
375
+
376
+ :param path: Optional path to the git executable. If not absolute, it is
377
+ resolved immediately, relative to the current directory. (See note below.)
378
+
379
+ :note: The top-level :func:`git.refresh` should be preferred because it calls
380
+ this method and may also update other state accordingly.
381
+
382
+ :note: There are three different ways to specify what command refreshing causes
383
+ to be uses for git:
384
+
385
+ 1. Pass no *path* argument and do not set the ``GIT_PYTHON_GIT_EXECUTABLE``
386
+ environment variable. The command name ``git`` is used. It is looked up
387
+ in a path search by the system, in each command run (roughly similar to
388
+ how git is found when running ``git`` commands manually). This is usually
389
+ the desired behavior.
390
+
391
+ 2. Pass no *path* argument but set the ``GIT_PYTHON_GIT_EXECUTABLE``
392
+ environment variable. The command given as the value of that variable is
393
+ used. This may be a simple command or an arbitrary path. It is looked up
394
+ in each command run. Setting ``GIT_PYTHON_GIT_EXECUTABLE`` to ``git`` has
395
+ the same effect as not setting it.
396
+
397
+ 3. Pass a *path* argument. This path, if not absolute, it immediately
398
+ resolved, relative to the current directory. This resolution occurs at
399
+ the time of the refresh, and when git commands are run, they are run with
400
+ that actual path. If a *path* argument is passed, the
401
+ ``GIT_PYTHON_GIT_EXECUTABLE`` environment variable is not consulted.
402
+
403
+ :note: Refreshing always sets the :attr:`Git.GIT_PYTHON_GIT_EXECUTABLE` class
404
+ attribute, which can be read on the :class:`Git` class or any of its
405
+ instances to check what command is used to run git. This attribute should
406
+ not be confused with the related ``GIT_PYTHON_GIT_EXECUTABLE`` environment
407
+ variable. The class attribute is set no matter how refreshing is performed.
408
+ """
373
409
# Discern which path to refresh with.
374
410
if path is not None :
375
411
new_git = os .path .expanduser (path )
0 commit comments