Hongmu Notes

git init

Initialize a new local Git repository

100% Browser local processing 0 Data upload

Common examples

Initialize a new local repository

git init

Initialize the repository and specify the name of the initial branch (usually defaults to `master` or `main`).

git init {{[-b|--initial-branch]}} {{分支名}}

Initialize the repository and generate an object hash using the SHA256 algorithm (requires Git version 2.29 or later).

git init --object-format sha256

Create a bare repository, which is suitable for use as an SSH remote repository.

git init --bare

Tip: curly braces{{…}}It is the parameter that needs to be replaced (path, file name, etc.); the command is only executed in the local terminal, and this site does not save any input.

English original text comparison

Expand English instructions and examples (source tldr-pages)

Initialize a new local Git repository. More information

Initialize a new local repository

git init

Initialize a repository with the specified name for the initial branch

git init {{[-b|--initial-branch]}} {{branch_name}}

Initialize a repository using SHA256 for object hashes (requires Git version 2.29+)

git init --object-format sha256

Initialize a barebones repository, suitable for use as a remote over SSH

git init --bare

command information

command namegit init
PurposeInitialize a new local Git repository
Applicable platforms通用
Number of examples4 Article
Official documentationhttps://git-scm.com/docs/git-init
Data sourcetldr-pages(CC-BY-4.0)· Community Chinese Translation

FAQ

git init What does the command do?

Initialize a new local Git repository

git init How to use it?

Pages listed by scene4Commonly used examples: Each example first explains the purpose, and then gives a complete command that can be directly copied (the parameters that need to be replaced are in the curly brackets).

git init What are the most commonly used operations?

Initialize a new local repository:git init

What do the curly braces in the command mean?

curly braces{{…}}Indicates that you need to replace it with your own value, such as path and file name; square brackets for parameters with the same name (such as[-C|--directory]) indicates optional writing.