Simple Introduction
Git is a version management system that can support version branching and multi-threaded version maintenance. You can use the Egit Client (command line), or you can use the graphical interface provided by Eclipse.
The purpose of this essay is to document the user's easy access to git in the Eclipse graphical interface.
The structure of the article is as follows:
(0) Basic concept (three storage areas of Git)
(1) Easy to get started (how to submit code on Eclipse, how to pull down code, how to handle conflicts)
(0) Basic concepts
git divides the local code into 3 repositories: the Git workspace (the user's actual files), the Git staging area (aka index, primarily for comparison), and the Git local repository (equivalent to a local official library)
Git's basic workflow:
(1) Git workspace file modification;
(2) Git workspace modification Submission index;
(3) Index content submitted to the local official library;
(4) Local official library push to cloud warehouse;
(1) Easy to get started
The next example will explain how to perform routine version maintenance in the case of two people (A, themselves; B, another person) maintaining the main version of the code together.
(a) projects without conflicts drop- down
When a git project already exists in Eclipse and B commits a file, a situation arises:
A requires a drop-down to update this B modified file.
operating methods are as follows:
Right-click Project->team->synchronize Workspace
See a blue icon file like this
If the confirmation is Code drop-down, you can perform pull actions in the Synchronize workspace
If there is a conflict, you can right-click on the file, perform override, overwrite the local, this time will create a conflict (blue arrow before the file changes into a red diamond), solve the other conflicts and then pull down once can be resolved, do not worry too much.
(b) No conflicting code uploads
When there is already a git project present in Eclipse, B does not commit the file, and a submits the file. The result is a situation where:
A need to submit your own changes to the Cloud library
operating methods are as follows:
Right-click Project->team->synchronize Workspace (make sure B is not committed)
See a gray icon file similar to this
Right-click on file->add to Index (add file to staging area)
Right-->commit The file (submits the file to the local official library)
When all the files are executed as above (the file can be submitted to the local library in bulk), you can execute the push action in the Synchronize Workspace and push the code to the Cloud warehouse
(c) Conflict Resolution
When both A and B modify the file, there is a conflict, and the icon looks like this (the Red diamond). This is going to be a conflict resolution for this file.
The solution is as follows:
File conflict, on behalf of two people modified the same file, the resolution of the results of no more than three kinds:
Local version Overlay Cloud library (discard each other's modifications), Cloud Library overlay Local (discard your own modifications) and merge both changes
Based on the above ideas, there are three ways of handling:
(1) Local coverage Cloud Library: Local file content first copied out, and then refer to the file merge walk, the last to submit the time, the original content back to the file and submit
(2) Cloud Library coverage Local: Right-click File->override, right-click File->add to Index,synchronize workspace pull
(3) file merging, see Operating methods.
operating methods are as follows:
Use the tool to merge the Cloud library and the local code: Right-click File->merge, and then check the file in the conflict code, find B with you to modify the contents of the file, to achieve the purpose of merging functions
Submit the merged code to the index area: Right-click File->add to Index
Perform a synchronize workspace pull to update the current file to the latest version of the Git Cloud Repository ID (this may cause changes to the code, remember to check)
Reciprocating execution as above 3 steps, until all conflicts have been resolved, the icon is programmed to submit the gray so far (note: Be sure to resolve all file conflicts, pull, will change), and then submit the code.
Git play on Eclipse (i)