Git learning Notes (2)-eclipse git plugin use

Source: Internet
Author: User
Tags how to use git

Currently I am using the Eclipse Luna version of the Git plugin has been integrated, here does not describe how to install the Git plugin, do not know to see other blogs.

The previous note introduced Git's basic instructions, I basically use the Eclipse plugin for code submission and update in real-world development, and the following describes how to use Git plugins in eclipse.

First look at a git management code schematic:

          

From this diagram, you know that git management code involves 4 places,

Remote repository, or remote branch, when a project is developed by multiple people, the remote repository is the central code base.

Repository: The local repository, as the name implies is installed in the local code base, which is the biggest difference between git and SVN, SVN is centralized management, each time to commit or update the code to connect to the remote repository, and git because there is a local repository, the code is first submitted to the local warehouse, Update to the remote repository when needed, meaning that local code submissions and updates do not need to be connected to the remote repository, and the code can be submitted and updated without a network.

Index: This is about the three states of git mentioned in the previous note, and when the code is managed by git, the state becomes modified after the code in the workspace changes (Eclipse shows a > tag on the code file), and you want to commit to the local repository. The code must first be submitted to staging area, the staging area is the index, and the instruction in Eclipse is add to index.

WorkSpace: The local workspace, this is not much to explain.

The following describes the actual work of code submission and merging, conflict resolution.

When you last updated the code to the remote repository, and now you're ready to write the code, pull the code from the remote repository, which merges the remote repository changes into the local code, and the benefit is that there's usually no need to manually resolve the conflict because you've pushed the local repository changes to the remote repository before. The changes behind the remote repository are also based on your code, and your local code has not changed, so merging is the best and easiest way to do this. Merge the code and then write the code.

Of course you can omit this step, write the code directly, write the code, add to Index--commit, and submit the code to the local repository.

Remember this time don't rush to the remote warehouse, because when you write code this period may be other people and you also modified a file in the same location, then you want to pull again, see the work Space code there is no red double arrow, if there is to manually resolve the conflict.

  

After resolving the conflict, add to index--commit again, preferably pull before updating to the remote repository, and then push the code only if there is no conflict.

This is the safest way to ensure that no one else's code is affected and there is no error.

Summary: Remember that when pushing code to a remote repository, remember the pull code, conflict resolution conflict, direct push without conflict.

By the way, pull and fetch similarities and differences, they are updated remote warehouse code to local, the difference is that after the fetch will need to merge a bit, and pull a command contains fetch and merge two operations.

And then say the similarities and differences between the merge and rebase, they are used to merge the code, different when the rebase operation is slightly more complex, but more careful, it will be remote files and local files to compare, and mark out the conflict, when the resolution of all conflicts after the add to index operation, Then do not immediately perform a commit operation, perform the continue rebase operation first, and then perform a commit operation. Did you have any trouble writing? If there is no continue rebase operation with the merge directive, but the conflict resolution is less obvious, he automatically merges the remote and local code locally and then marks it in the form. Executes the add to index--commit operation after resolving the conflict. So it depends on your personal preferences.

Git learning Notes (2)-eclipse git plugin use

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.