@@ -1031,7 +1031,10 @@ def init(
10311031 object_format : t .Literal ["sha1" , "sha256" ] | None = None ,
10321032 branch : str | None = None ,
10331033 initial_branch : str | None = None ,
1034- shared : bool | str | None = None ,
1034+ shared : bool
1035+ | Literal [false , true , umask , group , all , world , everybody ]
1036+ | str
1037+ | None = None ,
10351038 quiet : bool | None = None ,
10361039 bare : bool | None = None ,
10371040 # libvcs special behavior
@@ -1045,28 +1048,58 @@ def init(
10451048 template : str, optional
10461049 Directory from which templates will be used. The template directory
10471050 contains files and directories that will be copied to the $GIT_DIR
1048- after it is created.
1051+ after it is created. The template directory will be one of the
1052+ following (in order):
1053+ - The argument given with the --template option
1054+ - The contents of the $GIT_TEMPLATE_DIR environment variable
1055+ - The init.templateDir configuration variable
1056+ - The default template directory: /usr/share/git-core/templates
10491057 separate_git_dir : :attr:`libvcs._internal.types.StrOrBytesPath`, optional
10501058 Instead of placing the git repository in <directory>/.git/, place it in
1051- the specified path.
1059+ the specified path. The .git file at <directory>/.git will contain a
1060+ gitfile that points to the separate git dir. This is useful when you
1061+ want to store the git directory on a different disk or filesystem.
10521062 object_format : "sha1" | "sha256", optional
10531063 Specify the hash algorithm to use. The default is sha1. Note that
1054- sha256 is still experimental in git.
1064+ sha256 is still experimental in git and requires git version >= 2.29.0.
1065+ Once the repository is created with a specific hash algorithm, it cannot
1066+ be changed.
10551067 branch : str, optional
10561068 Use the specified name for the initial branch. If not specified, fall
1057- back to the default name (currently "master").
1069+ back to the default name (currently "master", but may change based on
1070+ init.defaultBranch configuration).
10581071 initial_branch : str, optional
10591072 Alias for branch parameter. Specify the name for the initial branch.
1073+ This is provided for compatibility with newer git versions.
10601074 shared : bool | str, optional
10611075 Specify that the git repository is to be shared amongst several users.
1062- Can be 'false', 'true', 'umask', 'group', 'all', 'world',
1063- 'everybody', or an octal number.
1076+ Valid values are:
1077+ - false: Turn off sharing (default)
1078+ - true: Same as group
1079+ - umask: Use permissions specified by umask
1080+ - group: Make the repository group-writable
1081+ - all, world, everybody: Same as world, make repo readable by all users
1082+ - An octal number: Explicit mode specification (e.g., "0660")
10641083 quiet : bool, optional
10651084 Only print error and warning messages; all other output will be
1066- suppressed.
1085+ suppressed. Useful for scripting.
10671086 bare : bool, optional
10681087 Create a bare repository. If GIT_DIR environment is not set, it is set
1069- to the current working directory.
1088+ to the current working directory. Bare repositories have no working
1089+ tree and are typically used as central repositories.
1090+ check_returncode : bool, optional
1091+ If True, check the return code of the git command and raise a
1092+ CalledProcessError if it is non-zero.
1093+
1094+ Returns
1095+ -------
1096+ str
1097+ The output of the git init command.
1098+
1099+ Raises
1100+ ------
1101+ CalledProcessError
1102+ If the git command fails and check_returncode is True.
10701103
10711104 Examples
10721105 --------
@@ -1115,6 +1148,13 @@ def init(
11151148 >>> git = Git(path=template_repo)
11161149 >>> git.init(template=str(tmp_path))
11171150 'Initialized empty Git repository in ...'
1151+
1152+ Create with SHA-256 object format (requires git >= 2.29.0):
1153+
1154+ >>> sha256_repo = tmp_path / 'sha256_example'
1155+ >>> sha256_repo.mkdir()
1156+ >>> git = Git(path=sha256_repo)
1157+ >>> git.init(object_format='sha256') # doctest: +SKIP
11181158 """
11191159 local_flags : list [str ] = []
11201160 required_flags : list [str ] = [str (self .path )]
0 commit comments