GIT-Every developer’s best friend

Hershil Piplani
2 min readNov 12, 2021

Part-2

Creating a local repository

Local repository in simple is the folder that you create in your local computer.

Initialize an empty local Git repository using git init.

  1. Create a demo directory for all your local repositories.
cd #change to user directory
#demo is the name of directory
mkdir demo

2. In your demo directory, create a project directory named firstLocalRepo. This will be your first local repository

cd demo
demo$ mkdir firstLocalRepo

Note: “demo$” in the above command means that we are currently in demo directory. By default, we are on main or master.

3. Change to your firstLocalRepo directory and initialize a repository.

demo$ cd firstLocalRepo

4. After the above command executes we are now into firstLocalRepo directory

# initializing repo
firstLocalRepo$ git init

5. we get an output like this : Initialized empty Git repository in firstLocalRepo/.git/

Creating a commit in your local repository

1. This creates a README file in your working tree.

echo "This is a demo that will make your day )" > Readme.md

2. Stage the README file

git add readme.md

3. The last step is to make a commit

git commit -m "Readme file is added"
#-m is a flag value that means message.

4. check the status as well as the commit history

git status -s
# -s is a flag value that means short.
git log
# check the commit history

That’s the end of part-2. To summarize we now know :

  1. What is a project directory.
  2. About Git and installing Git.
  3. How to customize configuration using git.
  4. how to create a local repository
  5. how to create a commit in a local repo and check the status and commit history.

Stay tuned for the next part:) and also

Please support me by following me and also am open to suggestions on how I can improve so please feel free to leave a comment :)

--

--

Hershil Piplani

An inquisitive person trying to create a measurable impact on the ecosystem through technology. Fan of oss and arsenal. 👉 https://github.com/herkura