Command

git init

Creates or reinitializes local repository metadata. In a new repository no commit is created. -b selects the initial branch; available since Git 2.28. Use a new dedicated directory for practice.

Formal Syntax & Structure

git syntaxgit
git init [-b branch-name] [directory]

Parameters & Attributes

NameTypeDescription
-b branch-namestringInitial branch name for a new repository.
directorypathTarget directory; defaults to current directory.

Working Example

Example Snippetgit
git init -b main
Git Reference