General action for Git in idea (merge, submit, new branch, update) __idea

Source: Internet
Author: User

Many people work with version control software collaborative development, common application scenarios are summarized as follows:

Suppose there are two people in the group, team leader Xiao Zhang, team member Xiao Yuan

Scene One: Small Zhang Create project and submit to remote Git warehouse

Scene two: Xiao Yuan from the remote Git warehouse to obtain the project source code

Scene Three: Xiao Yuan modified part of the source code, submitted to the remote warehouse

Scene Four: The small Zhang obtains the small yuan's submission from the remote storehouse

Scene Five: Xiao Yuan accepted a new feature of the task, created a branch and developed it on the branch

Scenario Six: Xiao Yuan submits the branch to the remote Git repository

Scene Seven: Xiao Zhang gets the branch submitted by Xiao Yuan

Scene eight: Xiao Zhang merges the branches into the trunk


Let's look at the corresponding actions in idea in the above scenarios. Scene One: Small Zhang Create project and submit to remote GIT warehouse

Create a project, select VCs-> Import into Version control-> create Git Repository


Next, specify the location of the local warehouse, as per personal custom, for example, where the project source code is selected in the same directory


Click OK to create a complete local warehouse, note that this is only local. Below the project source code to add to the local warehouse.

The following figure is what git does with the three commands that are submitted, the Add command adds the file from the IDE's working directory to the stage area of the local warehouse, commits the staging file for the stage area to the current branch's warehouse, and empties the stage area. The push command synchronizes the commit of the local warehouse to the remote repository.


In idea, the operations are simplified, and the commit and push can be done in one step.

Click the right button on the item and select Git menu




Because it is the first submission, the address of the remote warehouse needs to be specified before the push. In the following figure, click Define remote, and in the pop-up window, enter the address of the long-distance warehouse.


scene Two: Xiao Yuan from the remote Git warehouse to obtain the project source code

That is, the clone project, which operates as follows:


Enter the remote warehouse address to be filled in when the small Zhang push


Next, you can clone the project from the remote repository to the local warehouse and IDE workspace by following the wizard. scene Three: Xiao Yuan modified part of the source code, submitted to the remote warehouse

This operation is basically consistent with the first submission process, respectively, with the ADD-> commit-> Push. Please refer to scene one scene four: The small Zhang obtains the small yuan's submission from the remote warehouse The update has two commands: Fetch and Pull,fetch are downloaded from the remote repository to the local origin/master, You can then manually compare the modifications to decide whether to merge to the local master library. The push is downloaded and merged directly. You can use the Pull method directly to simplify the operation if each member performs a specification that is updated before it is modified in the work.


scene Five: Xiao Yuan accepted a new feature of the task, created a branch and developed it on the branch

Building a branch is also a common operation, such as temporarily modifying bugs, developing uncertain whether to join the function, etc., you can create a branch, and then wait for the right time to merge into the backbone.

The creation process is as follows:


Select New Branch and enter a name for the branch


When you're done, note the bottom right corner of idea, as shown in the following figure, Git:wangpangzi_branch says that you have automatically switched to the Wangpangzi_branch branch and are currently working on this branch.

Click to pop up a small window, there are other available local branch options in the branches, click to select Checkout to switch the current work of the branch.


The following figure, click Checkout


Note that the branch created here is only in the local warehouse, and if you want to get the leader to this branch, you also need to commit to the remote repository. Scenario Six: Xiao Yuan submits the branch to the remote git repository

Switch to a new branch and use the push feature



scene Seven: Xiao Zhang gets the branch submitted by Xiao Yuan

Using the pull feature to open the Update window, click the Refresh button at the back of the remote bar to refresh the new branch in the branches to merge bar. Do not want to merge here, so do not select any branches, directly click the Pull button to complete the operation.


After the update, and then click on the lower right corner, you can see in the remote branches area has a new branch, click on the Pop-up submenu to select Checkout as new local branch, the branch is created in the warehouse. After completion in the local branches area will also appear in the branch of the option, you can press the above method, click to select Checkout switch.


scene Eight: Xiao Zhang merges the branches into the trunk

The new feature was developed and experienced well, and the project team decided to merge the functionality into the backbone.

Switch to Master branch, select Merge Changes


Select the branch you want to merge, click Merge to complete


Copyright NOTICE: Welcome reprint, Reprint please keep the original link. https://blog.csdn.net/autfish/article/details/52513465

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.