@@ -1035,7 +1035,10 @@ def init(
10351035 object_format : t .Literal ["sha1" , "sha256" ] | None = None ,
10361036 branch : str | None = None ,
10371037 initial_branch : str | None = None ,
1038- shared : bool | str | None = None ,
1038+ shared : bool
1039+ | Literal [false , true , umask , group , all , world , everybody ]
1040+ | str
1041+ | None = None ,
10391042 quiet : bool | None = None ,
10401043 bare : bool | None = None ,
10411044 # libvcs special behavior
@@ -1049,28 +1052,58 @@ def init(
10491052 template : str, optional
10501053 Directory from which templates will be used. The template directory
10511054 contains files and directories that will be copied to the $GIT_DIR
1052- after it is created.
1055+ after it is created. The template directory will be one of the
1056+ following (in order):
1057+ - The argument given with the --template option
1058+ - The contents of the $GIT_TEMPLATE_DIR environment variable
1059+ - The init.templateDir configuration variable
1060+ - The default template directory: /usr/share/git-core/templates
10531061 separate_git_dir : :attr:`libvcs._internal.types.StrOrBytesPath`, optional
10541062 Instead of placing the git repository in <directory>/.git/, place it in
1055- the specified path.
1063+ the specified path. The .git file at <directory>/.git will contain a
1064+ gitfile that points to the separate git dir. This is useful when you
1065+ want to store the git directory on a different disk or filesystem.
10561066 object_format : "sha1" | "sha256", optional
10571067 Specify the hash algorithm to use. The default is sha1. Note that
1058- sha256 is still experimental in git.
1068+ sha256 is still experimental in git and requires git version >= 2.29.0.
1069+ Once the repository is created with a specific hash algorithm, it cannot
1070+ be changed.
10591071 branch : str, optional
10601072 Use the specified name for the initial branch. If not specified, fall
1061- back to the default name (currently "master").
1073+ back to the default name (currently "master", but may change based on
1074+ init.defaultBranch configuration).
10621075 initial_branch : str, optional
10631076 Alias for branch parameter. Specify the name for the initial branch.
1077+ This is provided for compatibility with newer git versions.
10641078 shared : bool | str, optional
10651079 Specify that the git repository is to be shared amongst several users.
1066- Can be 'false', 'true', 'umask', 'group', 'all', 'world',
1067- 'everybody', or an octal number.
1080+ Valid values are:
1081+ - false: Turn off sharing (default)
1082+ - true: Same as group
1083+ - umask: Use permissions specified by umask
1084+ - group: Make the repository group-writable
1085+ - all, world, everybody: Same as world, make repo readable by all users
1086+ - An octal number: Explicit mode specification (e.g., "0660")
10681087 quiet : bool, optional
10691088 Only print error and warning messages; all other output will be
1070- suppressed.
1089+ suppressed. Useful for scripting.
10711090 bare : bool, optional
10721091 Create a bare repository. If GIT_DIR environment is not set, it is set
1073- to the current working directory.
1092+ to the current working directory. Bare repositories have no working
1093+ tree and are typically used as central repositories.
1094+ check_returncode : bool, optional
1095+ If True, check the return code of the git command and raise a
1096+ CalledProcessError if it is non-zero.
1097+
1098+ Returns
1099+ -------
1100+ str
1101+ The output of the git init command.
1102+
1103+ Raises
1104+ ------
1105+ CalledProcessError
1106+ If the git command fails and check_returncode is True.
10741107
10751108 Examples
10761109 --------
@@ -1119,6 +1152,13 @@ def init(
11191152 >>> git = Git(path=template_repo)
11201153 >>> git.init(template=str(tmp_path))
11211154 'Initialized empty Git repository in ...'
1155+
1156+ Create with SHA-256 object format (requires git >= 2.29.0):
1157+
1158+ >>> sha256_repo = tmp_path / 'sha256_example'
1159+ >>> sha256_repo.mkdir()
1160+ >>> git = Git(path=sha256_repo)
1161+ >>> git.init(object_format='sha256') # doctest: +SKIP
11221162 """
11231163 local_flags : list [str ] = []
11241164 required_flags : list [str ] = [str (self .path )]
0 commit comments