Getting started with the actual combat git-branch in idea

Source: Internet
Author: User
Tags commit

Working with multiple people using version control software for collaborative development, common application scenarios are summarized as follows:

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

Scenario One: Xiao Zhang creates a project and submits it to a remote git repository

Scenario two: Xiao Yuan gets the project source from the remote Git repository

Scene Three: Small yuan modified some source code, submitted to the remote warehouse

Scene four: Xiao Zhang from the remote warehouse to get the submission of small yuan

Scenario Five: Xiao Yuan accepted a new feature 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

Scenario Eight: Small Zhang merges branches into the trunk


Here's a look at the actions of the above scenarios in idea. Scenario One: Xiao Zhang creates a project and submits it to a remote git repository

Create a good project, select VCs-> Import into Version Control---Create Git Repository


Next specify the location of the local warehouse, according to personal custom, such as the selection of the project source code the same directory


Click OK to create the local repository, note that this is only local. Add the project source to the local repository below.

The following figure is a list of the three commands that git has to commit, and the Add command adds the file from the IDE's working directory to the staging area of the local repository, commits the staged file to the current branch of the repository, and empties the stage area. The push command synchronizes the commit of the local repository to the remote repository.


Idea has a certain simplification of operations, and commit and push can be done in one step.

To do this, right-click on the project and choose the Git menu




Because it is the first commit, you need to specify the address of the remote repository before push. After clicking Define remote, enter the remote repository address in the popup window as shown below.


Scenario Two: Xiao Yuan gets the project source from the remote git repository

That is, cloning the project, the operation is as follows:


Enter the remote warehouse address to fill in the small push


Next, you can clone the project from the remote repository to the local warehouse and the IDE workspace by following the wizard. scene Three: small yuan modified some source code, submitted to the remote warehouse

This operation is basically the same as the first commit process, which is Push, ADD, Commit, respectively. Please refer to scene one scene four: Xiao Zhang get the submission of Xiao Yuan from remote warehouse get update There are 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 the local master library. The push is downloaded and merged directly. If each member performs a specification that is updated prior to the change, the pull method can be used directly to simplify the operation.


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

Branching is also a common operation, such as temporarily modifying bugs, developing features that are unsure of whether to join, and so on, you can create a branch and wait for the right time to merge into the trunk.

The creation process is as follows:


Select New Branch and enter a name for the branch


After creation, note the bottom right corner of idea, as shown below, Git:wangpangzi_branch indicates that it has automatically switched to the Wangpangzi_branch branch and is currently working on this branch.

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


As shown below, click Checkout


Note that the branch created here is only in the local repository and will need to be submitted to the remote repository if you want to get the team leader to this branch. Scenario Six: Xiao Yuan submits the branch to the remote git repository

Switch to the new branch, using the push feature



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

Use the Pull function to open the Update window and click the Refresh button after the remote bar to refresh the new branch in the branches to merge bar. Do not want to merge, so do not select any branch, directly click the Pull button to complete the operation.


After the update, 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, in the local warehouse to create the branch. After completion in the local branches area will also appear the option of the branch, you can follow the above method, click and select Checkout switch.


Scenario Eight: Small Zhang merges branches into the trunk

The new feature was developed and the experience was good, and the team decided to incorporate the feature into the trunk.

Switch to the Master branch and select Merge changes


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

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.