ComputersSoftware

Git - what is it? Git for Beginners: Description

Many of those associated with software development have heard of Git. What are these three letters? It is very important to understand the description, as well as the principles of functioning, in order to further effectively use this version control system, in which, unlike other similar systems, absolutely different concepts about information, work with it, despite a similar user interface. So, what is Git?

Description

Git is a distributed system for version control of the developed files. It was created in 2005 by the author of Linux OS. This system synchronizes the work with the site, and also saves and updates changes in files. This is a very convenient approach in case of working on a project of several developers. To date, many famous projects use Git. What is the use of giving? For example, the development of the operating system Android is engaged in a large number of programmers. It would be extremely inconvenient, if one of them made changes, and others did not know about it. Git also allows everyone to be aware of all the changes, and in case of errors, go back to previous versions of the files.

Using snapshots, not patches

The main difference between Git and other version control systems is how it looks at the data. Most of the programs store information in the form of a list of changes, called patches for files. Such systems to stored data refer both to a set of files, as well as a set of changes that are made for each file, relative to time. How does Git store its data? What is there in this system that distinguishes it from others? Instead of patches, the stored data is considered to be a set of snapshots of a small file system. Whenever the user captures a new version of the project, the system simply saves the file status snapshot to the current moment. To improve efficiency in the case when the file did not change, the system does not save it, but makes a link to the previously saved instance, to which the last changes were made.

This is a very important difference from other control systems, which is inherent in Git. What does this difference mean? Git looks like a small file system, which has very powerful tools that work on top of it.

Primarily local operations

In order to perform most operations in Git, only local resources and files are needed. This means that most often there is no need for information on other computers in the network. Since all project changes are on the disk, the operations are performed at lightning speed. For example, to view the history of a project, it does not need to be downloaded from the server. It is read from the local repository on the computer. If you want to see the changes between the version of the file that was made a month ago and the current one, you can do it very quickly without referring to the server.

Another local work means that you can do a lot of things without connecting to the network. For example, a developer can make changes while in transport. In many control systems, there is no such possibility.

Monitoring Data Integrity

Before saving any file, it is assigned an index in the form of a checksum, calculated directly by Git. What is a checksum? This value is calculated using special algorithms and is used to check the integrity of the data during storage and transmission. It is impossible to change anything without the knowledge of Git, and this is an important part of the philosophy of the system.

Data is most often added

Almost all actions performed in Git are added to the database. It is very difficult to remove them. You can only lose the information that is not yet stored, but with its fixation, the loss is excluded. For this reason, many choose exactly Git, because here you can conduct experiments without risks to do something irreparable.

File states

Working with Git for beginners involves remembering that a file can be in one of three states:

  • Fixed, that is, the file is stored in the local store.
  • Changed when edits have been made, but the save is not yet done.
  • Prepared - modified files that are marked for saving.

For example, in projects that use Git, there are three sections for different file states:

  • The Git directory, where metadata is stored, as well as a database of objects. This part of the system is the most important.
  • A working directory that is extracted from the database by a copy of some version of the project.
  • A file containing information about the subsequent saving.

Installing Git

The first thing you need to do in order to use the version control system is to install it. There are several ways to do this. The main are two options:

  • Installing Git from source.
  • Install the package for the platform you are using.

Installing Git from Source

If such an opportunity exists, it is better to use this option, since the latest version will be obtained. Each update usually contains many useful improvements regarding the user interface. That's why if installation from the source is not too difficult for you, it's better to prefer it. And most Linux distributions include obsolete packages.

To install, you will need the necessary libraries: expat, curl, libiconv, openssl, zlib. After installing them, you can download the latest version of the version control system, compile it and install it.

Installation in the Windows operating system

If the user does not have Linux, but wants to use Git, Windows also supports this system. And to install it is very simple. There is a msysGit project, the installation procedure of which is one of the easiest. You just need to download the installer file, which you can find on the project page in GitHub, and then start it. At the end of the installation on the computer there will be two versions - a graphic and a console version.

Initial Git Setup

After the monitoring system is installed on the computer, you need to perform some actions to configure the environment for the user. This is done once. When updating, all settings are saved. They can be changed at any time.

Git includes the utility git config, which allows you to make settings and monitor the system, as well as the appearance. These parameters can be stored in three places:

  • A file containing values that are common to all users and repositories.
  • In a file containing the settings of a specific user.
  • In the configuration file located in the current repository. Such parameters are valid only for him.

User name

First of all, after installation, you must specify the user name, as well as e-mail. This is very important, since each commit (state preservation) contains this data. They are included in all transmitted commits and can not be changed afterwards.

If you specify the -global option, you will need to do this one time.

Selecting a text editor

After specifying the name, you need to select the editor that will be needed when composing messages into Git. By default, the standard operating system editor will be used. If the user wants to use another, you need to register this in the configuration file settings in the core.editor line.

Verify settings

To know the basics of Git, you need to be able to check the settings used. To do this, use the git config -list command. It displays all available parameters that can be found. Some settings names can be listed several times. This is due to the fact that Git reads one key from different files. In this situation, the last value is used for each key. It is possible to check the values of certain keys by typing in the command instead of "--list" - "{key}".

How to create a repository

There are two ways to achieve this goal. The first is to import an existing catalog or project into the system. The second is cloning from the server of an existing repository.

Creating in this directory

If the user decides to start using Git for an existing project, he must go to the directory and initialize the system. To do this, you need the git init command. It creates a subdirectory in the directory where all the necessary files will be located. At this stage, version control of the project is not yet installed. To add files under control, you need to index them and make the first commit changes.

Cloning the repository

To obtain a copy of an existing repository, you need the git clone command. With it, Git will get a copy of almost all the data from the server. This applies to all versions of each file. A very convenient option, since in the event of a server failure, the programmer can use a clone on any client to return the server to the state in which it was cloned. This is similar to the recovery point.

Deleting a file in Git

You can delete any file from the system if you exclude it from the index, that is, from the monitored files. To do this, you need the git rm command. It also removes the file from the user's working directory. Then you need to commit. After it, the file simply disappears and will no longer be tracked. If it is changed and is already indexed, then forced removal with the -f option is used. This method will prevent the deletion of data that has not yet been recorded in the status snapshot and which can not be recovered from the system.

Cancel changes

At any time there may be a need to cancel an action. If the user performed the commit early, forgetting to make some files, then you can overfulfill it using the --amend option. This command uses the index for the commit. If no changes were made after the last save, the project will be in the same state, and a comment editor will appear where the user can edit everything that is needed. It must be remembered that not every cancellation operation can be canceled. Sometimes you can permanently delete the necessary data. Be careful.

Results

Now the user should form an idea of what Git is, why this version control system is needed than it is different from other similar products. It is clear that to fully familiarize you need to install a working version of Git with personal settings for you. Do not interfere with any tutorial or video course on Git for "dummies", which can step-by-step guide the user through all phases of working with the system.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.unansea.com. Theme powered by WordPress.