How Git works

The main task of Git is to keep track of code versions and allow developers to go back to any previous state if necessary. This is done by taking a snapshot of every version and maintaining it in a local file storage system. Unlike other systems, Git uses local file storage to store snapshots, which means that Git can be used locally—even without an internet connection. With the local version of Git, you can do almost everything that you can do with an internet-connected version of Git.

After you install Git in your project, you can choose which directory of your filesystem you want to keep under Git version control. Normally, a project or directory—which is one entity in Git—is called a repository. A repository might contain different projects, one project, or just some of the project files, depending on what you want to keep in Git version control. There are two ways that you can have a Git repository on your local machine. Either you can initialize a Git repository by yourself, or you can clone a repository from a remote server. Either way, you will create a folder called .git in the same folder in which the repository was created or cloned. This .git file is the local storage file, all the information related to that repository will be stored there. Git stores data in a very efficient manner, so the file won't get very big, even if you have tons of snapshots.

There are three main states in Git, which we will explore in the following sections:

  • Modified
  • Staged
  • Committed
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.247.16