Version controller-how to use Egit and how to use the Controller egit

Source: Internet
Author: User

Version controller-how to use Egit and how to use the Controller egit

What is Git?

Gitv is currently the most advanced distributed version control system in the world.

So why do we need to learn about Git? In our traditional java self-study, all projects are independently developed and basically all projects are small projects. In terms of optimization and experience, they are often inferior to formal company products. When we enter the company and formally participate in the company's large-scale projects, you will find that a project is developed by 5-20 or more programmers, the cooperative development requires a version controller. On the one hand, it records the code versions updated each time, and on the other hand, it Concatenates the things developed by various programmers. Therefore, we need to use Git.

The entire running mode of git is shown in this way. Every programmer first pulls the project code from the GIT library to his computer, then write the corresponding code on your computer and submit it to the git repository. In this way, the Code pulled by others from the git repository is the project code you have added.

The specific process is as shown in. After pulling the code from cloud git and modifying it, commit submits it and then plush it to the cloud database. During this period, if someone else pulls a version that is the same as you, and the content submitted for modification conflicts (modifying the same java class ). The simplest method is to pull it from the cloud database, merge it locally or change it to a unified version, and then submit it to the new version of the cloud database. (In actual development, we recommend that you pull the latest version each time you perform plush to avoid conflicts)

Git records the changes rather than the entire file. The Code submitted and pulled each time is not actually the whole project, but the version has changed during the period. It may be a class or several classes, which is very simple for us.

Git is also powerful. Because of this mechanism, GIT can easily perform operations such as "time regressing". If you are not satisfied with the latest submission, you can return to the previous version. In addition, we can compare the specific code of two versions.

 

Install Egit

As soon as we learned java, I also recommend that you start learning from the Eclipse plug-in EGit that is commonly used by the company. As for GIT, if you have this need, you can study it on your own, compared with Egit, there is a lot less information. Here, the moderator will take you to see and learn from the perspective of the actual effect.

 

1. open eclipse, find help, and search for Egit (because the EGit version may be updated, you should not only look at the icon, but you can do whatever EGit ), click the button in the lower-right corner to install the SDK.

 

2. Configure before using EGit

 

Configure personal information. The most important items are user. name and user. email.

L Preferences> Team> Git> Configuration

L New Entry

 

3. dsa key of Egit

The dsa key of Egit is equivalent to your password. It is used to store asymmetric encryption key files used by the SSH protocol and is required for remote git database connection.

1)Eclipse: Window-> preferences-> General-> Network Connections-> SSH2

 

2)Click Browse to select a folder. The format is normal. SSH is a hidden folder. If no folder exists, you can create a new setting to hide it.

3)On the Key Management page, click Generate DSA key to Generate the Key, fill in the password, and save it to the folder above.

 

Git remote Library Construction

Generally, companies all have their own remote libraries. Here we use our personal exercises. We mainly introduce github. The actual operation is not too bad, so it never changes.

Github Official Website: https://github.com/

 

 

Click "Add SSH Key", fill in any Title, and paste the content of the id_rsa.pub file in the Key text box:

Click "Add Key" to view the added Key:

 

Why does GitHub need an SSH Key? Because GitHub needs to identify that the submission you push is indeed pushed by you, rather than impersonating others, and Git supports the SSH protocol, GitHub only needs to know your public key, you can confirm that only you can push.

 

Of course, GitHub allows you to add multiple keys. Assume that you have several computers. If you submit them at the company and submit them at home later, you only need to add the keys of each computer to GitHub, you can push data to GitHub on each computer.

 

Finally, the Friendly reminder is that anyone can see the free Git repository hosted on GitHub (but only you can change it ). Therefore, do not include sensitive information.

 

If you don't want others to see the Git repository, there are two ways: one is to pay the protection fee and let GitHub convert the public repository to private, in this way, others will be invisible (neither readable nor writable ). Another method is to build a Git server by yourself. Because it is your own Git server, no one else can see it.

 

Then, log on to GitHub, find the "Create a new repo" button in the upper right corner, Create a new Repository, and enter the "Repository name" in the Repository name. Keep the default settings for others, click "Create repository" to Create a Git repository.

 

 Click your profile in the color pattern in the upper-right corner to view your warehouses.


Click to enter the repository to view the repository URL for pushing and cloning. (The naming rule is https://github.com/user name /warehouse name .git, which can be noted down)

 

 

Egit Common Operations

1. Open eclipse to create a project, or write the project to be submitted. Right-click the team-shared directory (you can translate the Chinese version of the moderator ).

 

 

2. Check both of them. If xxxx cannot be checked, click create repository and confirm. In this way, you can change your project to a git project.

 

 

3. After the code is modified, right-click the team and you will find that it has changed. Click the first commit to submit the project from the local workspace to the temporary storage area.

 

4. in the dialog box that appears, unstage change is the code that you do not want to submit, and stage changge is the code you want to submit. Click the code to be submitted and drag it to the following box, then enter the message (the information submitted this time is generally filled in with the modified content. For example, the logon interface is optimized .) You can submit it.

5. Right-click the team again and click "--" push Branch ** to push the project to the remote repository. Enter the URL of the library shown above in URI, automatically generate the Host and path, and enter the username and password to push. Note: The SSH code must be correct.

 

 

 

 

Supplement

1. MARK: Will projects with no commit Changes in the j2ee workspace be in front of the corresponding file? Prompt: comiit will be marked> if not pushed

2. clone to local:Window->Perspective-> open the perspective (translated by yourself # Cute)-> Git, click the icon, the same parameter can be used to clone the project in the library to a local location.

Make sure to enter your eclipse workspace and check the address. After downloading from the database to the local computer, right-click the git view and you can import it to the j2ee view for editing.

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.