Explaining Git Concepts
What is Git?
The first mistake that people make or what happens in a beginner's mind when they hear Git is that, they try to relate it to a similar word that they know which is GitHub.
Buster: they are different, GitHub is more like a file storage used for keeping files that use Git.
So what is Git? Git is what we call a version control system. Now we have another big word- Version Control System. A version control system is a tool used to monitor changes in your files, during your development process. So it keeps track of the changes that are made to your files. Hence Git helps you to track changes in your files, it helps you determine the changes made to files, who made it, when it was made, and why the changes was made which is usually communicated through commit messages
In relation to Git, a repository is a storage space where your files and all the versions of your files are saved. Repository is usually shortened to and called repo. In Git there can be local repository and remote repository. A Local repository is that repository that is stored on your local machine and no other person has access to the repo except you. While a remote repository is one that is stored on an online storage that anyone can have access to. So it is remote because it is not stored on your local machine or rather personal computer but it is stored in another server that can be accessed by your team members over the internet.
Before we proceed it is good that we define a technical term which is known as commit. A commit is simply a revision or a change made to a file or set of files. It is like saving a file on your computer. A commit adds the latest changes you made to files in the source code to the repository.
In Git, we have what we call Branches. Imagine it as branches in a tree, so when we start making changes to our files we create a 'master' branch which is like the main trunk of the tree but it might come to a time when we want to make some changes to the files and don't want to do so on the master branch we create another branch which is sort of like a copy of the master branch, but the changes made to files in one branch will not be reflected in the other branches.
Git allows us to combine branches when we want to and this concept is called merging i.e. merging two branches together. But sometimes problems occur when you want to merge two branches together, and the kind of error that occurs is called merge conflicts. This occurs when you have made changes to the same part of a single file in the different branches, when git want to merge the two branches it becomes confused on which revision to keep and which not to keep.
In Git, a file can be in three states:
- Modified: this means that the file has been changed but has not been stored in your local repository.
- Committed: this means that the file has been edited and stored in your local repository.
- Staged: it is a step before committing the changes to your local repository and creating a version, it allows you to prepare the files for committing. After a file has been staged, a version is not yet created but when it is committed, a version is created.
So I hope I pretty much explained some of the concepts you need to understand when working with Git.
Drop a comment, like and please share.