git init command
git initThe command is used to create a new Git repository in a directory.
Execute in the directorygit initThen you can create a Git repository.
After executing git init, Git will create a hidden folder named .git in the current directory, which is used to store all metadata and objects required for version control.
Basic Usage
git init
For example, let's create a project named example in the current directory:
Example
$ cd example/
$ git init
Initialized empty Git repository in /Users/xxx/www/example/.git/
# Empty Git repository initialization completed.
Now you can see that it has been generated in your project..gitThis subdirectory is your Git repository, where all content and metadata related to your project are stored.
After completing the above steps, you have created a new Git repository. You can use other Git commands (such as git add, git commit, etc.) to manage and track your code changes, and interact with remote repositories.
Note: The git init command is only used to create a new repository in an empty directory. If you want to clone an existing remote repository to your local machine, please usegit clonecommand.
.gitIt is hidden by default. You can view it with the ls -a command:
ls -a . .. .git
other extensions