What is Git?
Git is a popular source control system that allows all users to work on small and large software projects in a very simple yet powerful way
Table of contents
No headings in the article.
In this article, we shall talk about some of the things we need to know about git:
- Git is a popular source control system. This means that it is widely used to track changes in your source code and other text files during the development of a piece of software.
- Git is also a distributed source management system. Being distributed basically means that instead of having a single place for all the sources, every developer also has a full history of all the changes.
- It was created by Linus Torvalds.
- Its also open source and completely free to use.
Why use Git?
Here are some of the reasons as to why someone should use git:- It is fast and scalable. Since it is distributed, you will often work with a local history and that too is a lot faster than working with a remote server . It works everywhere and its widely supported on all operating systems.
- It can work disconnected . When working with git, every developer has a full local copy of the complete repository. All the work is done in the local repository and only when you are satisfied with the work you have done, you can synchronize it with the remote server.
- It is powerful yet easy to use. One can easily become a git expert in a very short time.
- It enables branching. The entire typical workflow in Git is based around branching. Development is typically done on the feature branch and only when the level of quality is where it should be will we be merging into the main branch. Therefore the main branch only contains the quality code.
- It enables collaborating on code through pull requests. Using a pull request, a developer can ask for a review and a merge into another branch of the changes that he or she has performed. This intrinsically brings discussion and reviews with it , thus improving the quality of the code.
How does Git work?
In order to use git , you need to have it installed on your machine. It works on a Command Line Interface (CLI) .Git can be installed on the most common operating systems like Windows, Mac, and Linux. In fact, Git comes installed by default on most Mac and Linux machines. visit this site to install gitWhat states can a file be in when a developer is using Git?
State of a file basically means the particular condition that a file is in at a specific time and these states include the following:1. Modified State: This means that the file has been changed but it has not been committed to the database yet. This basically done by editing ( add, remove ) data in the file.
2. Staged State: This means that the modified file is marked to be part of the next commit snapshot. This is done by typing the $ git add
command on the command line (CLI)
3. Committed state: This means the data is basically stored in the local database for example your computer. This also done by typing the $ git commit
command on the CLI
1. Working directory: This is where content will be created, edited and deleted.
2. Staging directory: An area where changes from the local directory will be staged before they are committed. When the files are in the staging area, they are waiting to be committed and they will be part of the next commit.
3. The .git repository: This is a local git directory that stores all the changes when a commit is performed. It is entirely managed by git itself.