Git init command

The git init command is used to create a new blank local git repository or reinitializing the existing one. It is used to make an existing project as a Git project. Several Git commands run inside the repository, but git init command can be run outside of the repository.


git init

The default branch name is master.

Initialize Repo with Specified Branch name


git init -b <branch-name>
git init --initial-branch= <branch-name>

The command git init -b main is used to initialize a new Git repository with a specified default branch name (main in this case).

Remove Git Repository

The following command is used to remove the .git folder which means the repo is no longer a git repo.


rm -rf .git

The command rm -rf .git is used to forcefully remove the entire Git repository, including all its files and history. It's a dangerous command and should be used with caution because it irreversibly deletes the Git repository.

If we run this command in a directory containing a Git repository, it will remove the repository and all its version history. Make sure we have a backup or are absolutely certain that we want to delete the repository before using this command.