“This is the 8th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”

Git is a distributed version control system, created by Linus Torvalds, whose original purpose is to better manage the source code of the Linux kernel.

PS:In order to help more Java enthusiasts, the Path to Java Programmer Advancement has been open-source on GitHub (this article has been included). This column has received 715 stars so far. If you also like this column and think it is helpful, you can click a STAR, which will also facilitate more systematic learning in the future:

Github.com/itwanger/to…

I am very happy to see the number of stars rising every day. I hope that more and more Java fans can benefit from this open source project, and more and more people’s stars will inspire me to continue to update

As you all know, the Linux Kernel is open source and there are many participants. So far, more than 20,000 developers have submitted code to the Linux Kernel.

But from 1991 to 2002, Linus, the project’s administrator, did not use any SCM tools, but manually combined the submitted code through Patch.

It’s not that Linus likes to do things by hand, but he’s very picky about code versioning tools, both commercial ClearCase and open source CVS and SVN.

It wasn’t until 2002 that Linus settled on BitKeeper, a distributed version control system that was commercially available, but was happy that BitKeeper was willing to make it freely available to the Linux community.

Back in 2005, a developer decompilated BitKeeper without permission and used an undisclosed interface because the default interface provided by BitKeeper was not sufficient for the Linux community. Larry McAvoy, the copyright owner of BitKeeper, angrily withdrew the Linux community’s right to use it for free.

Linus had no choice but to take it on himself. He has a number of goals for the new version control system:

  • speed
  • Design simple
  • Allows for thousands of branches of parallel development
  • Completely distributed
  • Ability to efficiently manage very large projects like the Linux kernel

As a result, surprisingly, Linus completed the first version in C in just 10 days. God is God. And gave it the slightly ironic name Git (British English slang for “unpleasant person”).

The readme file of the source code has further elaboration:

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your way)

In terms of Git design, there are two kinds of commands: basement commands and Porcelain commands. At first, Linus designed Unix KISS commands for the open-source community, called plumbing Commands because hackers are hands-on and roll up their sleeves to fix broken pipes.

Linus released the Git tool to the community after committing his first Git commit. Junio Hamano, a developer in the community who found the tool interesting, downloaded the code and was surprised to find only 1,244 lines of code, which sparked a lot of interest. Junio communicated with Linus on the mailing list and helped add functions like Merge, then continued to polish Git until Junio took over git maintenance completely and Linus went back to work on the Linux Kernel project.

Junio Hamano felt Linus designed these commands to be less user-friendly for the average user, so he built on top of them more easy-to-use, higher-level commands with better interfaces, like git add and Git commit, which we use every day today. Git add encapsulates update-cache and Git commit encapsulates write-tree and commit-tree.

If I were to pick the greatest Git commit of all time, it would be the first Git tool project itself. The code submission was groundbreaking. If the Linux project led to the success of open source software and changed the landscape of the software industry, Git has changed the way developers around the world work and write.

Today, Git has become a standard for software developers around the world.

Originally, Git was only suitable for Unix/Linux platforms, but with the maturity of Cygwin and msysGit, as well as the easy-to-use GUI tools like TortoiseGit, Git is becoming more and more mature on Windows platforms.

PS1: Cygwin’s primary purpose is to port software from POSIX systems (such as Linux, BSD, and other Unix systems) to Windows by recompiling.

PS2: The first four subtitles of msysGit are from the MSYS project, which in turn derives from MinGW (Minimalist GNU for Windows), and by adding a shell environment and other tools from Bash, It is composed of a Minimal System, using the tools provided by MinGW and a branch version of Git for MinGW, it can compile a native application for Git on The Windows platform, combined with MSYS to form msysGit.

Git is quite different from traditional version control tools like CVS and SVN. The former is concerned about whether the integrity of files is changed, while the latter two are more concerned about the differences in file contents.

Beyond that, Git is more like a file system, and every host that uses it can act as a repository and work offline without relying on remote repositories. Developers have local copies of historical versions, so they are no longer tied to network transfers from remote repositories.

Most operations in Git only require access to local files and resources, and generally do not require information from other computers on the network. Because you have the full history of your project on your local disk, most of Git’s operations can seem instantaneous.

In the case of multi-party collaboration, Git can copy the local repository to other developers, and the changed files can be imported as new branches and merged with the local repository’s branches.

If you want Git to go smoothly, remember these three states:

  • Committed: Indicates that data is safely saved in the local database
  • Modified indicates that the file has been modified but not saved to the database
  • Staged means that the current version of a modified file has been marked to be included in the next submitted snapshot

This introduces three Git work areas:

  • Git repository, used to hold metadata and object databases for projects
  • A working directory that independently extracts a version of a project
  • A staging area that holds a list of files to be submitted next time, also known as an index.

Git works like this:

  • Modify files in the working directory
  • Temporary file, a snapshot of the file into the temporary storage area
  • Commit the update, locate the files in the staging area, and store the snapshot permanently to your Git repository directory

Next, let’s look at the Git installation, Linux and Windows installation you can go to the Git official website to view the installation method, the above is very detailed.

git-scm.com/downloads

For my personal macOS, you can install it directly using the brew install git command.

Git –version = 2.23.0


References:

Wikipedia: zh.wikipedia.org/wiki/Git ProGit: www.progit.cn/ hutusi: a code submitted to change the world

This is the 73rd installment of the Java Programmer Advancement Column (click star). The column is funny, accessible, and extremely friendly and comfortable for Java enthusiasts 😄, The content includes but is not limited to Java foundation, Java Collection framework, Java IO, Java concurrent programming, Java virtual machine, Java enterprise development (Maven, Git, SSM, Spring Boot) and other core knowledge points.

Github.com/itwanger/to…

Let’s become better Java engineers together!