The use of Git Gui + About SSH protocol and cloning corresponding file code + IDEA integration with Git, etc.

Table of Contents

1. Use of Git graphical interface

1.1 Preparation

1.2 Use of Git graphical interface

1.2.1 File code cloning

1.2.2 Check the effect of file GIt management

1.2.3 Git Gui page details illustration

1.2.4 Git Gui function demonstration effect

(1) Temporary storage

(2) Submission and comments

(3) Push remote push

2. SSH protocol

2.1 Definition

2.2 Features

2.3 The difference between SSH protocol and SSL/TLS protocol

2.3.1 Design purpose and application scenarios

2.3.2 Communication methods

2.3.3 Ports and protocols

2.3.4 Identity verification method

2.3.5 Application areas

2.3.6 Working level

2.4 What is SSH Key

2.5 Use SSH protocol to clone the corresponding file code

2.5.1 Preparation

(1) Remote warehouse code status

(2) Set SSH public key

2.5.2 SSH protocol clone file code

(1) Cloning steps

(2) Effect after cloning

3. IDEA integrates Git

3.1 Configure the git.exe file

3.2 Install Gitee plug-in

3.3 Log in to Gitee in IDEA

3.3.1 Generate Token

3.3.2 Log in to Gitee

3.4 Upload the project to Code Cloud (project sharing)

3.2 IDEA clones the uploaded code cloud code

3.2.1 Copy the SSH path of the file code

3.2.2 Clone code

3.3 Submit push code in IDEA

3.3.1 Submit

3.3.2 Push

3.4 Update code in IDEA that is not pushed by you

3.5 Modify the problem of merging similar codes

1. Use of Git graphical interface

1.1 Preparation

Gitee creates a new warehouse. The specific operations are as follows:

d3ad48f9eb924e45a73a744b09570ef9.png

Initialize readme file:

f4355641f082446986a6ec270b4b6122.png

The effect after initialization is completed:

de59b93bfc254559a5cf56371203cacd.png

1.2 Use of Git graphical interface

1.2.1 File code cloning

Then go back to the local resource manager and create a new path, then right-click the mouse to open Git GUI here, and the specific operations are as follows:

c48fc4c294e644679b0c25169a87e008.png

It should be mentioned here that if you use Git Bash to clone the code according to the previous blog, you must use the command git clone. If you use Git Gui, you do not need to use the command operation.

The specific operations are as follows:

f63cf122cea14a1fba4ba044530aa93b.png

3787f429c0574a598e388f22e4160e0e.png

d777d5289f424b6ca897ca87320a6581.png

The effect after cloning:

ef5e2894738d41cc8ea59076a4aa15f9.png

1.2.2 Viewing the effect of file GIt management

You can see that there is nothing in it at this time. At this time, we create a new Person.java and write some code in it, as follows:

b8265f0e4a9641648b40b7281a144fe0.png

faaa06c32fee4e008c7009b82d167a34.png

Then save, return to the Git Gui interface, click refresh, and you will see the file we just created, as follows:

caa560788da246e38acda395ad0d7159.png

At this time, we will change the java code in the newly created Person, and add a sql file containing the query statement in the directory where the Person is located, as follows:

76fa1dae1ad84b44a6fba5d5e63cd2ec.png

Then go back to the Git Gui interface to refresh. The refreshed interface is as follows:

356969b0df8341538dd0bcc347a34231.png

Then we temporarily save the Person. The operation and effect are as follows:

6e3542580f5242d2ab68fd259b450b2f.gif

In fact, we can roughly see it here. Compared with the command window, the Git Gui graphical interface can greatly speed up our operation time and improve our development efficiency.

1.2.3 Git Gui page details illustration

Here we need to first understand some details of the Git Gui interface, as follows:

36191ef3a7834d47930be82aca341184.png

1.2.4 Git Gui function demonstration effect

(1) Temporary storage

The temporary demonstration effect is as follows:

f7bf3237c63b4a9fbfee9c9e0981cd1d.gif

(2) Submission and comments

Submit and annotate the demonstration effect as follows:

7a1b3ac12eaf4ec8b616ead06d4a98bd.gif

(3) Push remote push

Before performing Push remote push:

fcc6734674b94887ad61e6c855f1305b.png

Remote push demonstration effect:

13dd46b8f3e141a8a00a432ab5d1eb3c.gif

After Push remote push:

b8baad2737bd4edd8ae90dfcf3d9a01a.png

2. SSH protocol

2.1 Definition

  • SSH (Secure Shell) is an encrypted network protocol used to run network services securely on insecure networks. The most common use of SSH is to remotely log into a computer system in a secure manner, but it can also be used to securely transfer files and perform a variety of network services. The main design goals of SSH are to provide strong authentication, encrypted communication, and data integrity.
  • There are two main versions of the SSH protocol, SSH-1 and SSH-2. SSH-2 is a newer version of the SSH protocol that has some improvements in security and functionality, while SSH-1 is obsolete. The way SSH works involves a secure connection between a client and a server, through which encrypted remote terminal access, file transfers, and command execution occur.

2.2 Features

The SSH (Secure Shell) protocol has the following characteristics:

  1. Encrypted Communication: The SSH protocol provides secure data transmission, using encryption technology to protect the confidentiality of communication. All data transmitted through the SSH protocol is encrypted, including usernames, passwords, executed commands and transferred files.

  2. Authentication: SSH supports multiple authentication methods, the most common of which are public key authentication and password authentication. Public key authentication is a more secure authentication method that reduces the risk of password leaks.

  3. End-to-end security: The SSH protocol provides end-to-end security, ensuring that data transmission between the local computer and the remote server is protected. Even when transmitting data over untrusted networks, you are not vulnerable to man-in-the-middle attacks.

  4. Remote access: SSH allows users to remotely connect to a remote host from a local computer, execute commands, and access a remote Shell session. This is very useful in server management and maintenance.

  5. File Transfer: SSH supports secure file transfer protocols such as SCP (Secure Copy Protocol) and SFTP (SSH File Transfer Protocol), allowing users to securely transfer files between the local computer and the remote server.

  6. Flexibility: The SSH protocol is very flexible and can run on different operating systems and platforms, supporting various encryption algorithms and authentication methods. This makes it suitable for a variety of environments.

  7. Multi-version support: The SSH protocol has two main versions, SSH-1 and SSH-2. SSH-2 is the newer, more secure version and is widely used, while SSH-1 is obsolete.

  8. Configuration and customization: Users can customize the parameters of SSH connections through configuration files to suit their needs. This includes defining authentication methods, specifying port numbers, setting keys, etc.

  9. Key management: SSH allows users to manage public and private key pairs, making it easier to authenticate. SSH agents can help users manage their keys efficiently.

  10. Known Hosts: The SSH client maintains a “known_hosts” file, which contains the public keys of known hosts. This helps prevent man-in-the-middle attacks because the client can verify the identity of the connecting remote host.

In short, the main feature of the SSH protocol is that it provides secure, encrypted remote access and file transfer services, is suitable for various computer network environments, and provides multiple authentication methods to ensure communication security. This makes SSH the tool of choice for many organizations and individuals for protecting sensitive data and remote management.

2.3 The difference between SSH protocol and SSL/TLS protocol

The SSH protocol and the SSL/TLS protocol are two different secure communication protocols. Althoughthey are both used for encrypted communication, there are some key differences in design purposes, usage scenarios, and working methods.

2.3.1 Design purpose and application scenarios

  • SSH (Secure Shell): Mainly designed for remote login and command execution. It provides a secure command line interface that enables users to perform operations on remote computers. In addition to remote login, SSH also supports functions such as secure file transfer and port forwarding.

  • SSL/TLS (Secure Sockets Layer/Transport Layer Security): It is mainly designed to protect the security of network communications and is widely used in encrypted communications between web browsers and servers. TLS is the successor of SSL, and the two are often referred to as SSL/TLS. SSL/TLS is used in web browsers to encrypt HTTPS connections, providing end-to-end encrypted communication, and can also be used in other applications.

2.3.2 Communication methods

  • SSH: Provides secure peer-to-peer communication, often used for remote management and control. SSH sessions are often conducted from the command line, but can also be used for remote desktop with a graphical user interface (GUI).

  • SSL/TLS: Typically used for end-to-end secure communication, such as between a browser and a web server, between a client and a server. SSL/TLS can be used for a variety of applications, not just remote management.

2.3.3 Ports and Protocols

  • SSH: Use port 22 by default, based on TCP protocol.

  • SSL/TLS: Usually based on HTTP, HTTPS is formed through encryption, and the port used is 443. Can be implemented on different application layer protocols, such as HTTPS (HTTP over TLS).

2.3.4 Authentication method

  • SSH: Supports multiple authentication methods, including passwords, public keys, and other methods.

  • SSL/TLS: Authentication is often done using digital certificates, where both the server and client can verify the identity of the other.

2.3.5 Application areas

  • SSH: Mainly used for system management, remote terminal access and file transfer.

  • SSL/TLS: Mainly used to encrypt Web communications and protect data transmission between the browser and the server.

2.3.6 Working Level

  • SSH: Works above the application layer and provides a secure command line interface.

  • SSL/TLS: Works on top of the transport layer to provide encryption and authentication services to the application layer.

Overall, although both SSH and SSL/TLS provide solutions for secure communication, they differ in design purposes and usage scenarios. SSH focuses more on remote management and terminal access, while SSL/TLS is widely used for security protection of network communications, especially encrypted communications between web browsers and servers.

2.4 What is SSH Key

An SSH (Secure Shell) key is an encryption key used for secure communication between computers. The SSH protocol is mainly used for remote login and command execution, as well as secure file transfer. SSH keys enable secure communication through asymmetric encryption technology.

An SSH key is a pair of keys, including public key and private key:

  1. Private Key: A private key is a sensitive file stored on the user’s local computer and is used to encrypt and digitally sign information. Private keys must remain confidential and should not be shared or leaked.

  2. Public Key: The public key is the public part paired with the private key and can be spread freely on the network. The public key is used to verify information or encrypted data signed by the private key. Other users can encrypt information using your public key, and only users with the private key can decrypt it.

The main purpose of using SSH keys is to ensure the confidentiality and integrity of communications while providing an authentication mechanism. When you connect to a server that supports SSH, you can authenticate using an SSH key pair instead of entering a password.

SSH key usage process:

  1. Generate key pair: By using the SSH key generation tool, you can generate a pair of public and private keys.

  2. Upload your public key to the server: The SSH service on the server needs to know your public key for authentication. Typically, you need to add the public key to the ~/.ssh/authorized_keys file on the server.

  3. Authenticate using private key: When you connect to the server, the SSH client will authenticate using the private key. If the private key matches the public key on the server, the connection will be authorized.

  4. Protect Private Keys: Since private keys are key to security, make sure that only you have access to the private key file, and use password protection where possible.

Using SSH keys provides greater security than password authentication because private keys are generally more difficult to guess or hack.

2.5 Use SSH protocol to clone the corresponding file code

2.5.1 Preparation

(1) Remote warehouse code status

Before using SSH to clone the code, we need to change the open source status of the remote warehouse (ie gitee code cloud) to private. The operation is as follows:

Click to manage:

3ad6a4139911478997058404de8a5e42.png

Change whether open source to private:

bd8c350bd218428d97ba3c4ea51f95e2.png

(2) Set SSH public key

Specific steps are as follows:

First open the local resources under the current user of the computer and find the .gitconfig file, as follows:

08565867edc041eaaa3473d43875ba97.png

Double-click to open the file with Notepad, and then copy the email address, as follows:

fc89127cbe3c4ea3a8c15d9275cf45e8.png

Then use the command to generate the key, the command is as follows:

ssh-keygen -t rsa -C "[email protected]"//The email here should be replaced with the email you registered with

The specific operations are as follows:

5c5038a3c24f4a93be8bae047c43c1e0.png

Then return to the computer user directory, as follows:

e0dba2bfc190419da22eb85c3c768334.png

Double-click it and you will find that two keys have been generated, one is the public key and the other is the private key, as follows:

eaafec0b8f084a45af66702518e68455.png

Then we double-click to enter the public key, copy the public key, and configure it on the Gitee code cloud. The specific steps are as follows:

98f17034f69d4f19a44fadf419c4805a.png

8cc6ff6e4f4748e4923282a917c22f31.png

6af7827ee3704215a48dfad6e223b08d.png

Public key added successfully:

cbdaefe6ba8044bd81b8562bf778a139.png

2.5.2 SSH protocol clone file code

(1) Cloning steps

Copy SSH on the Gitee repository as follows:

c21e6457305244c2a42ea6e188bd558f.png

Then open the command window to clone, as follows:

d44bf1f38536455aa09f80187c4d2966.png

54863b36ecb54a35bbc796d14e2918c7.png

(2) Effect after cloning

Then enter Yes to clone successfully, the effect is as follows:

46e66cc12ad440e0bb7aeb28e09c7a4b.png

3. IDEA integrates Git

Hypothetical case:

When you create a new project and need to host it on gitee, perform the following steps:

Configure the git.exe file in IDEA.

Install the gitee plug-in in IDEA (because git.exe is used with GitHub by default).

Log in to Gitee in IDEA.

Log in to Gitee in IDEA.

Share the built projects.

3.1 Configure git.exe file

Open IDEA, click File–>Settings, and then search for git. After entering the following interface, the specific operations are as follows:

382dde51c1dd4991b4b0bcddf52b1975.png

After the configuration is completed, test it. After the test is successful, you can apply it:

64aba64ffd4b498b806dca81c08710ee.png

3.2 Install Gitee plug-in

Because by default git.exe is used with GitHub, we need to download the Gitee plug-in. Default:

cf170f77012b46cf8178b8ef17ce5e8f.png

Search plugins, click plugins, enter Gitee search above to download and then restart IDEA.

3.3 Log in to Gitee in IDEA

3.3.1 Generate Token

Return to the Gitee interface, click Private Token, and click Generate New Token. The specific operations are as follows:

9449bd08b40743b595c7be83414bf225.png

Then customize the private token description and submit:

384e5212f87b485ba8e473570bef158c.png

Then enter your Gitee password to verify your identity, as follows:

62fe31eadd6e4c62aa2d348b4f42db1d.png

The private token is generated successfully, as follows:

48fcff7f3f284f3c8b93a037bff28136.png

Finally, copy the Token private token so that you can log in to Gitee later in IDEA.

3.3.2 Log in to Gitee

The specific operations are as follows:

408a91df549d40e38e94b599ee5abd2a.png

18603ec8ab3140f599bb6659cf5f0038.png

1bd5dc7510d0446dae40bb1c39f484c3.png

Then click Log in to log in. The effect after logging in is as follows:

14d1adcd02774f6f94f952b929ad75ae.png

3.4 Upload the project to Code Cloud (project sharing)

The specific operations are as follows:

After selecting the project you want to upload, find VCS in the upper navigation bar and do the following:

a35ccc826431437f956fd3f52275338d.png

Then click to select private and fill in the corresponding information, then click share, as follows:

e05ef49e0fba434f9b6542fba7f32ea3.png

The effect after uploading is as follows:

fac7c65b9110438684effbbc233d8868.png

46430fe7a7794ee7b727e465a8e3954d.png

3.2 IDEA clones the uploaded code cloud code

3.2.1 Copy the SSH path of the file code

1a2f6035730945b9af7e9b1b2ff0fa5a.png

3.2.2 Cloning code

Specific steps are as follows:

c55a455108e5409bb21b75f71f738e10.png

942d71bc6c734bc78c1844e3e7a36091.png

Then click Clone and click Yes.

3.3 Submit push code in IDEA

3.3.1 Submit

651a414cf2814a24bf8fe41c3b5591c5.png

After Add is added, execute commit submission, as follows:

89db2e3a92774087a6e39e1f41324c28.png

5ac23fecad7d4655a147afa848fe8095.png

3.3.2 Push

The specific operations are as follows:

4579f4bc52a14e4d8a256ca41083de08.png

7553c9a2d16c46fa8d6ae0d60fae8fad.png

Push successful:

5475badef72840679e59fd681c7d8e11.png

The effect on Gitee:

68fc57da4c7d4486aed5218d4a3999a0.png

3.4 Update code in IDEA that is not pushed by you

But at this time, the user who uploaded the code has not updated the code, as follows:

46d889469c9f4ac2a4a533201558c673.png

So we need to get the updated code.

The specific operations are as follows:

6c81095697504e4281081432715e8d2e.png

3.5 Modify the problem of merging similar codes

Added code:

109aa6515e0b4d77bd532f720cee8ff7.png

547e60f1b7ea455f9d484560ee1639ab.png

Add code on another computer:

af62352396bf4e2aa15419835c419835.png

Push failed on another computer, and the following interface appears after push:

456eddbad0894ecfa6a2bf96fd295908.png

Effect after Merge:

9e5b8b09f6ed4398bfff7bbcc05a4cf7.png

I found an error here, so I tried again, as follows:

IDEA1 page code:

38fcbab7433f4fa2bfa2db7564cd5ec1.png

IDEA2 page code:

3e3cfd27dfbf4db6b55899c1c4580315.png

The final result is as follows:

90641544f60a444cb7e01cc590794161.png

Finally, the use of Git Gui + about SSH protocol and cloning corresponding file code + IDEA integration of Git, etc. are here. I wish everyone a smooth journey on the road to typing code!

Thank you for watching!

97c3cf201e1947caa514b2de27b427db.png