top of page

Git Tutorial

Create A Git Repository

What Is A Git Repository ?

Git Repository is a store of structured data that contains a collection of project files of various different versions of a project along with their history.
Every Git Repository will have a hidden '.git' folder to enable GIT programs to track changes in the repository.

How To Create A Git Repository ?

There are different approaches to create a Git Repository enlisted below :
  • Create a bare git repository in a new project directory

  • Initialize git repository in an existing project directory

  • Clone a remote repository from a git service provider like Github

Let's create a project/folder as 'AutomationHub' for our own relevance which will be our root project folder and here, we will work on various Git Repositories :
  • Search 'git cmd' in the system search bar.

  • Open git cmd.

  • Use command ' mkdir <foldername> ' to create a project/folder.

Create a Bare Git Repository in a New Project Directory
  • Open git cmd.

  • Navigate to the root project folder 'AutomationHub' by entering command ' cd automationhub '.

  • Enter command ' mkdir BareGitRepo ' to create a new project/folder named 'BareGitRepo'.

  • Navigate to this folder with command ' cd BareGitRepo '.

  • Enter the command ' git init ' to create a Git Repository. It creates a hidden '.git' folder inside the browsed folder or we can say, it initializes an empty Git Repository.

  • To view the the content of newly initialized Git Repository, enter command ' dir /ah '.

Initialize/Create Git Repository in an Existing Project Directory
  • Open git cmd.

  • Navigate to the directory in which the Git Repository have to be created. In my case, I've a project named 'Sample Project' within root project folder. Therefore, enter the command ' cd automationhub/sampleproject '.

  • It already has few files for demo purpose as it can be view by executing command ' dir '.

  • Initialize the Git Repository by using the same command i.e. ' git init '.

  • It will initialize an empty Git Repository.

Clone a Remote Repository from a Git Service Provider(Github and few more)
In the context of Git, clone is a local copy of the Remote repository. The remote repository is hosted on a server and we can clone it on our local system.

  • Copy the url of the remote repository.

  • Open git cmd.

  • Navigate to root project folder 'AutomationHub' by entering command ' cd automationhub '.

  • Create a directory to store the source code.

  • Enter the command ' git <repourl> ', to initialize the Git Repository.

  • At the place of 'repourl', we have to pass the copied url of the remote repository.

  • Finally, repository is created.

Refer next page Git Staging Environment
bottom of page