GIT-Every developer’s best friend
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.
- 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 :
- What is a project directory.
- About Git and installing Git.
- How to customize configuration using git.
- how to create a local repository
- 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 :)