In this article we are going to see how we can create a git repo.
How to Create a Git Repo?
There can be two cases while creating a git repo.
- Creating a new repo from scratch
- Creating a repo from an existing directory
To create a new repo from scratch follow the below steps-
- Create a new directory from the menu or by using the command.
$ mkdir dir_name
This will create a directory in the working folder with the name specified.
- Navigate into the new directory using the command
$ cd dir_name
- Now to create a repo use the command
$ git init
This will create a git repo in that directory. From there you can add files to the git repo.
- After adding your files commit by the command
$ git commit
Now, to create a repo for a pre-existing project,
- Navigate into the directory using cd command
- Now to create the repo use the command
$ git init
- Add the files to the repo using
$ git add
- Commit the changes using
$ git commit