Graph tutorial for using git in IntelliJ IDEA, intellijgit

Source: Internet
Author: User
Tags how to use git using git

Graph tutorial for using git in IntelliJ IDEA, intellijgit

Project management cannot be separated from version control. Currently, major version control tools are SVN and Git. The differences between the two are not described in detail. If you do not understand the differences, you can check the information online, in the future, if you have the opportunity, I will elaborate on the opening section, and now the Git usage on the market is much higher than that on SVN. How can we use Git to control code versions when using IDEA development projects?

1. Install Git

To use Git, you must install Git first. The installation process is not described in detail. After the installation is completed, open IDEA to enter the settings page (you can directly click on the toolbar, you can also use the shortcut key Ctrl + Alt + S) to search for git. The interface is as follows:

We can see that Git is on the Version Control tab, and there is a GitHub in it. You can configure your GitHub account and password, and then pull the code on GitHub directly. For more information, see the previous articles on Settings.

Go on to Git, Path to Git executable the git.exe directory under the bindirectory in our gitinstallation folder. After the route is complete, click the Test button. If the installation is correct and the Path is correct, the following dialog box is displayed, indicating that the configuration is successful:

2. Remotely pull the Git library code

We often pull the code from the company's Git library or GitHub to the local for development. How can we pull the code in IDEA? There are actually two ways to achieve our goal. Let's take GitHub as an example:

1. Use the git tool to pull the code locally and then open it through IDEA.

Copy path

Clone to local

lq@DESKTOP-BHJ6UD2 MINGW64 /e/mygit/20180226 (master)$ git initReinitialized existing Git repository in E:/mygit/20180226/.git/lq@DESKTOP-BHJ6UD2 MINGW64 /e/mygit/20180226 (master)$ git clone https://github.com/noobgod/designPattern.gitCloning into 'designPattern'...remote: Counting objects: 73, done.remote: Total 73 (delta 0), reused 0 (delta 0), pack-reused 73Unpacking objects: 100% (73/73), done.

Pull successful, path in local E:/mygit/20180226, open the project under this path in IDEA, follow the steps.

2. Pull the Code directly through IDEA. We recommend this because it is convenient and convenient.

After you select the mode, multiple options are available. If you select Git, a dialog box is displayed, and you can click the Clone button.

3. update)

Before submitting the code, we 'd better update the code of the remote repository to the local repository to reduce unnecessary conflicts, update can be directly implemented through the shortcut key Ctrl + T or by pressing the buttons on the toolbar, namely update, commit, and compare with the same respository version. Here we select update.

Of course, you can also right-click the project --> select Git --> Respository --> pull to implement it.

4. Submit code (commit and push)

How can we submit our code to a remote repository after we open it in IDEA? Right-click the project and select Git.

1. commit Directory: commit code (submit the temporary files in the stage area to the local repository of the current branch and clear the stage area ), you can also push the code (synchronize the files in the local repository to the remote repository ).

In IDEA, the file is marked with different colors: Red, green, and blue. What do they mean?

RED: files that are not under version control, that is, files that are not added to version control, for example, files that are added to ignore.

Green: the new version of the file, that is, the file we created, has not been submitted to the remote repository.

Blue: Modified file, that is, the file already exists in the remote warehouse. We modified it this time, but it has not yet been submitted.

The Commit command corresponds to the Git Commit command. This method can be used if you only want the commit to be pushed to the local repository. If we still need to push to the remote repository after the commit is complete, we need to right-click the project --> select Git --> Respository --> push.

To implement the simple commit function, you can also press Ctrl + K or the toolbar button.

Commit and Push are Commit and push. Here we can directly commit to the local warehouse and then push to the remote warehouse.

2. Add: Add the local file from the working directory to the stage area of the local repository, corresponding to the Git Add command.

3. Compare with Branch... : Compare with remote branch. Before submission, we can use this function to compare the similarities and differences between code in our working directory and remote branch code.

4. Show History: view the modified version History.

5. Revert: roll back the local modification.

6. Repository: Various Repository commands.

V. Merge)

In development, it is inevitable that many people will modify the same file, resulting in version conflicts. In this case, if the program needs to run properly and ensure the function is complete, developers need to manually resolve these conflicts and merge the code, finally, the Code with the final consistency is pushed to the remote device.

This is often the biggest headache for many people. Improper Operations may cause code disorder and cause accidents. In fact, they understand the principles and are not as complicated as they are skilled.

There are a lot of content to be introduced here and I need to elaborate on it. If you are concerned about this, you can pay attention to it and add and supplement it occasionally in the future.

Vi. Branch Management

Branch management requires the status bar at the bottom of IDEA.

Here we can switch the branch, create a branch, checkout branch code, and compare branch code.

Summary

The above section describes how to use git text tutorials in IntelliJ IDEA. I hope this will help you. If you have any questions, please leave a message and I will reply to you in a timely manner. Thank you very much for your support for the help House website!

Related Article

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.