| by Arround The Web | No comments

Beginner Tutorials – What is a Git Repository?

Git is a version control system to stage all changes made in the development project files and folders. After that, store them in the Git local repository. Developers can perform multiple operations, such as creating a new repository for ongoing projects, copying the existing directory, or deleting the new and existing directories.

This blog will illustrate:

Let’s move ahead!

What is a Git Local Repository?

A Git repository is used to update and store the history of all modifications in source code in the development projects. It saves this data in a Git repository called “.git”, which is also known as a repository folder.

How to Commit Changes in Git Local Repository?

To commit changes, first, we will move to the Git directory and initialize it. Next, perform the operation of creating and adding a file to the local repository. Then, execute the “$ git commit” command with the “-m” flag to commit changes.

Now, let’s implement the above-discussed steps!

Step 1: Navigate to Git Directory

Run the “cd” command to navigate to the desired repository:

$ cd "C:\Users\nazma\Git\Comments"

Step 2: Initialize Directory

Now, initialize the current Git local repository:

$ init

Step 3: Create File

Next, create a new file using the “touch” command:

$ touch file2.txt

Step 4: Track New File

Add the newly created file to the staging area through the provided command:

$ git add file2.txt

Step 5: Update to Directory

Add changes to the Git repository by executing the “git commit” command with “-m” flag:

$ git commit -m "New file added"

Step 6: Check Status

Lastly, run the “git status” command to check the current repository status:

$ git status .

We have explained what a Git repository is and the procedure to commit changes in the Git repository.

Conclusion

A Git repository is used to update and save the history of all changes that are made to the source code in the development projects. For committing changes, first, move to the Git directory and initialize it. After that, perform the operation of creating and adding a file to the local repository. Lastly, execute the “$ git commit” command song with a message to commit changes. In this blog, we have explained what a Git repository is and the method related to committing changes in a Git repository.

Share Button

Source: linuxhint.com

Leave a Reply