- Developers who already know basic commit and branch actions
- Readers who want to understand command boundaries and risk
Command Reference
git init Tutorial
Explains how git init creates a repository, how the initial branch is defined, and how it is used for both new and existing directories.
- A basic mental model of worktree, index, and commits
- Comfort reading `git status` and a small commit graph
- Using local cleanup commands on already shared history
- Continuing to rewrite before confirming a recovery path
The short version
git init creates a new Git repository structure in the current directory so version control can begin there.
Common use cases
- starting a new project under Git
- bringing an existing directory under version control
- creating a local experiment repository quickly
Basic usage
git init
git init -b main
Important note
git init does not create the first commit. It only creates the repository metadata. The real history starts with your first commit.
What problem this command solves in a workflow
git init is about repository initialization, configuration, and how Git should behave by default. It may not appear every hour, but it influences whether the rest of your workflow stays stable and predictable.
Typical use cases
- Use
git initwhen bootstrapping a new repository, setting up a machine, or establishing shared team defaults. - Put
git initinto onboarding and environment validation flows so "works differently on my machine" issues get caught earlier. - When debugging behavior differences, use
git initin a clean directory to quickly create a control repository that eliminates old configuration interference.
Diagram view
Repository directoryConfig scopesHelp topics
Initialized stateEffective configReference documentation
The value of this category is often not an immediate commit, but making all later commands more stable and predictable.
Special cases and boundaries
- Configuration and initialization commands may not cause immediate incidents, but once defaults are wrong, many later commands will continuously deviate from expectations.
- If you are using
git initin a team environment, it is best to write key default configurations into documentation or scripts, rather than relying solely on personal memory. - When behavior disagrees with documentation, first inspect config scope, aliases, and local environment differences.
Previous / Next
PreviousNo more reads in this direction
Nextgit clone TutorialCommands