git init
The command that turns the current directory into a Git repository by creating the hidden .git directory.
In more detail
After git init the repository has no commits yet: .git/HEAD names a branch, such as main, that will be created by your first commit. Running it again in the same place is safe and prints Reinitialized existing Git repository. Running it inside another repository creates a nested repository, which is almost always a mistake.
Example
mkdir my-project && cd my-project && git initRelated terms
- repository — A project folder whose full history is tracked by version control; in Git, your files plus the hidden .git directory that stores every commit.
- .git directory — The hidden directory at the root of a repository where Git keeps all of its data: objects, refs, HEAD, config and the index.
- nested repository — A Git repository created inside the working tree of another one, usually by running git init in the wrong folder.
- bare repository — A repository that is only the Git database, with no working tree, used as a shared place to push to and fetch from.
- Git — A free, open-source distributed version control system that records the history of a project as a chain of snapshots.
Taught in
- Installing Git, And Telling It Who You Are — Advanced Git Internals & Distributed Workflows
- A Repository Is A Folder With A Memory — Advanced Git Internals & Distributed Workflows
- What A Remote Actually Is — Advanced Git Internals & Distributed Workflows
- Shipping: scripts, entry points and git — Hands-on Python: Complete Video Course & Book
- Recovering From Boot, File System And Disk Failures — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Git For Admins: Who Changed That, And How To Undo It — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Booting: Firmware To Login, And Where To Step In — LPIC-1 Linux Administrator (101-500 and 102-500) Exam Prep