Git is a free, open source distributed version control system that can handle projects from small to large quickly and efficiently.

Git is easy to learn, small footprint, and extremely fast. It features inexpensive local libraries, convenient staging areas, and multiple workflow branches. The performance is better than Subversion, CVS, Perforce, ClearCase and other version control tools. Attach a website

What is version control

Version control is a system that records changes to the contents of a document so that future revisions to a particular version can be reviewed. In fact, the most important is to record the file modification history, so that users can view the historical version, convenient version switch.

So why version control? It’s for better teamwork. For example, if you are not the only one writing the code file of a project, then after you submit it first, someone else’s copy without your code, when he submits it again, your code will be overwritten.

Second, centralized and distributed

Versioning tools can be roughly divided into two categories: centralized and distributed.

What is centralized? SVN, for example, has a single centrally managed server that holds revisions of all files. All participants in the collaboration connect to the server via a client to retrieve the latest files or submit updates. One of the big disadvantages of this system is a single point of failure of the central server, such as being down for an hour, during which no one can submit updates and work together.

What is distributed? Git is a distributed version control tool. The client first clones the code repository completely from the remote repository to the local repository, so that the local version can be controlled. You can develop even if the remote server is down, but there is no way to push local code to the remote repository. In addition, each clone to the local is a complete project, including the history and so on, more secure, no longer afraid of single point of failure.

3. Git working mechanism

Git is powerful, but the working mechanism is not complicated, after all, Linus only spent two weeks to develop the Git system by himself. You say what? Linus is who?

Lin is the father of Linux, so Git and Linux are the same father. At the beginning of 10 years, Lin is his own manual to match the Linux code, and then more and more people submit the code, their own match

Too tired. Then a company developed a commercial version control software that was freely available to the Linux community for humanitarian reasons, as long as you didn’t crack it. But then one of the programmers cracked it, and the company took it back,

Helpless, Lin da Lao can only use C language to develop this distributed version control system.

  • Workspace: is where we write code, specifically the disk directory where the code is stored.
  • Staging area: In order for Git to keep track of code you write in your workspace, add code to the staging area.
  • Local library: if you commit the staging area code to the local library, the corresponding historical version will be generated. This historical version cannot be deleted.

Git and the code hosting center

A code hosting center is a web server-based remote code repository, commonly known as a remote repository. Examples include Internet-based GitHub, Gitee, and LANS-based GitLab.

Once the code has been committed to the local repository, it can be pushed to the remote repository using git push.

Five, the installation

Install will not say, open the official website, download the latest version of the corresponding system, all the way default installation on the line.

The next chapter organizes git common commands.