Common Git commands
So far in this book, we have discussed the following Git commands. Let’s discuss them in more detail.
Setting up a repository
Here are some commands to use when setting up a repo.
Creating a new repository with git init
The git init command initializes a new Git repository. This command sets up all the necessary files and directories that Git uses to track changes in your project. Until you do this, the directory is regarded as an ordinary folder with no version control.
- Steps:
- Open your terminal or command prompt.
- Navigate to the directory where you want to create the repository.
- Run the
git initcommand. - Git will create a new
.gitdirectory in your project folder, indicating that the repository has been initialized.
- Usage:
git init - Example:
mkdir myapp cd myapp git init