Git(getting a git repository)

MrArc
2 min readFeb 9, 2022

In this article, I will show you the two ways you can get a git repository

Getting a git repository

You can get a git repository in two ways namely;

  • Initializing a repository in a directory or existing project
  • Cloning an existing Repository

Initializing a repository in a directory or existing project

This method takes an existing project or directory and imports it into Git. You can use the command;

git init

This creates a new subdirectory named .git that contains all of your necessary repository files.

Example:

Creating a folder called myProject (mkdir myProject)

  • Creating two files named file1.txt and file2.txt inside the folder (cd myProject && touch file1.txt file2.txt).
  • while in the myProject folder run command git init.
initializing a new git repository with two files in it
  • Finally opening the folder will have the following structure.

If you have an existing project not yet tracked by git, simply go into the folder in a terminal window and type git init, which imports your existing project into git for tracking.

Cloning an existing repository

if you want to get a full copy of an existing project which is in git repository, for example, a project you will like to contribute to the command you need is;

git clone

Example:

if you want to clone a project on Github, with its URL link as below

https://github.com/Afoudo-Richard/buy_me_a_coffee_clone_vue.git

simply run the command

git clone https://github.com/Afoudo-Richard/buy_me_a_coffee_clone_vue.git

which will copy the entire project to your local computer and create a directory called buy_me_a _coffee_clone_vue, initialize a .git directory inside it, pull down all the data for that repository, and checks out a working copy of the latest version.

--

--