Basic knowledge
Software Testing | Git Operations for Code Farmers (1)
preface
Nowadays, everyone uses Git for code and version management in their daily work, but many beginners are not familiar with Git and are not familiar with its operation. Therefore, I would like to write a few articles to systematically introduce and operate Git.
introduce
Git is an open source distributed version control system. The biggest difference from SVN is that it is centralized. The version library of a centralized version control system is placed on a central server, and its operation must rely on the central server. If there is no network or the central server hangs, almost everyone will not be working anymore.
Distributed version control refers to everyone having a complete version library on their computer. It's okay if one computer crashes, just copy one from someone else. Even without a network, code version management can be completed locally. However, in order to facilitate collaboration among multiple people, a version repository will be created remotely to host the code, such as Github, Gitlab, and so on, for everyone to synchronize and share. This is just a formal "central server", without which everyone can still work independently.
Git environment installation
This article takes the Windows system as an example to introduce the installation of Git environment.
Download the git installation package
The Git download address requires downloading the corresponding installation package according to your operating system. For 32-bit systems, download the 32-bit installation package, and for 64-bit systems, download the 64-bit installation package, as shown in the following figure:
Install Git
There are no other operations to install Git, just click 'Next' all the time
Configure Git environment variables
Configure the bin directory of the git installation directory to the environment variable of the computer, as shown in the following figure. After the configuration is completed, click OK.
After the configuration is completed, open the cmd command line to check if the configuration is successful
git --version
The version information shown in the following figure indicates successful configuration:
Configure username and email
After completing the environment configuration, we need to confirm our username and email for future version management and code hosting.
We can right-click on the desktop ->Git Bash Here
Git config -- global user. name "username"
Git config -- global user. email "email address"
To view configuration information:
git config --global --list
Generate Key
Ssh keygen - t rsa - C "email address"
View Key
Cd~/. ssh # Enter the key storage directory
cat id_ Rsa. pub # View Public Key
Set up Gitee account
As we mentioned earlier, Git is a distributed version control system that allows us to manage code through a common remote repository, enabling branch development and backbone publishing. GitHub, Gitlab, and Gitee are all remote warehouses that we can use.
GitHub is currently the most mainstream open source code repository management platform, but due to network issues, our access is often limited. Therefore, this article will not take GitHub as an example to introduce it.
Gitlab is mainly a code repository management platform for private deployment, which is more used for internal product development within the enterprise and has fewer individual users.
Gitee is a Git based code hosting service launched by Open Source China (OSChina) and has become the largest code hosting platform in China.
Gitee does not often experience access failures due to restricted access, so this article takes Gitee as an example. GitHub and Gitlab operations are also similar to Gitee, and we will not go into detail here.
To use Gitee, the first step is to register our own account.
Open the browser and enter the Gitee registration address, as shown in the following figure
Set email address
Hover in the upper right corner ->Settings ->Email Management ->Add, enter the email address, and click OK.
Add public key to Gitee
We also need to copy and paste the public key we just generated onto Gitee as our identity credentials when uploading the code.
Settings ->Security Settings ->SSH Public Key
This completes the configuration of the public key.
summary
This article mainly introduces the environment for installing Git and the content of registering and configuring Gitee accounts. Later, we will also introduce Git knowledge such as creating warehouses and branch management.