What is Git Repository | How to Create Git Repository Examples

What is Git Repository How to Create Git Repository Examples

Git repository is the top-level working directory that contains everything about your project. The top level working directory probably contains many sub directories, your source code, data files, etc.. one of the sub directories named .git. Git repository is used to manage our project and all our files as they change over time. it is just a file location where we store all the files related to our project. in this post i will show you how to create a git repository with different examples.

Example of Git Repository

what is git repository

Every git repository contains .git folder.

Create Git Repository

git repository

To create a git repository in your system you must and should have git installed in your system. if not install git in your system. Once git is installed, you can begin creating new repositories. The first step in creating repository is Create an empty folder and this folder nothing but your top level working directory for your repository. Once you created an empty folder enter into that folder.

Git Init

creating git repository

The first command that you will execute in your top level directory is git init command. The git init command will create a .git directory that contains all the metadata of your git repository. That’s it you have successfully created a git repository in your system. Creating a .git folder is nothing but creating a git repository. repository name is nothing but top level working directory name.

After Creating (.git) folder  we can start working on our git repository. we can create new files in the top level directory or git repository. Using Linux touch command we can create files. 

how to create a git repository

Git Status

git status command will show you the changes you have done in the repository. once your work is done on that files you start adding those files to git. 

git add

Git Add

we add files to git repository using git add <filename> command. Git add command add files to git repository and tells Git to start tracking of your files changes. once we added files to git repository we can do git commit.

Configure email and username for repository

for the first commit, we have to configure email and username for our repository. so we can identify the all commits with email and username.

git config –global user.email “you@example.com”
git config –global user.name “YourName”

to configure email and username use above commands. this username and email are global level configuration in our system or laptop. once you configured email and username in your laptop or system, for the next time no need to create, by default git will take our global configured email and username.

Git Commit

git commit

So for now we have done so many steps, lets combine all and take a snapshot of all repository or files. Git commit function takes all previous additions and makes them permanent in the repository’s history in a transnational action.

Git Log

verify our commits or snapshots of our branch with git log command. git log command will show you all the commit in your branch.

git log

 

in the git log command you can see my commit and commit author name,email.commit message, commit date and time. Using author section you can identify who committed that particular commit.

Lets Create one more new Git repository

git repository example

 

Leave a Reply

Your email address will not be published. Required fields are marked *