In the company for more than a year, the use of the project is to use SVN code hosting, no Git, while the National Day holiday a little self-taught, and then lazy, reluctant to use the form of the original Knock command line, in the eclipse learn how to use git, say back with SVN to learn git, it is easy and difficult, The difficulty is that GIT commands more, and it takes time to get started. I learned to use a git tutorial, which is very good, easy to understand, he knocked on the command line, I translated into how to operate in Eclipse, but also learn.
Liaoche git tutorial Address:
http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
- About Git
This section can be directly read the introduction of the Liao Xuefeng Tutorial, understand the essence of SVN and git difference is more important.
2. Create a repository and basic operations
What is a repository? Repository also known as the Warehouse, English name repository, you can easily understand a directory, all the files in this directory can be managed by git, each file modification, deletion, git can track, so that any moment can be traced to the history, or at some point in the future can be "restored."
In a Java project, the entire project is a repository, git management, Eclipse is integrated git plug-ins, we only need to right-click on the new Project team-"Share project-" select git-"and then complete the operation, the final finish
The successful words are the following:
There is a small arrow that indicates that Git has started hosting the project.
Then we write a Java file under this project
Finally we submit this file to the Git repository: Right-click Project team-"Commit
In the Liaoche tutorial, a file is submitted to add and then commit,egit as long as commit can default to add the non-monitored files to the index and then commit the update, do not need to separate operation (add to index in Egit can add files to git index, version monitoring)
Also note that the notes must be written, the following file to be submitted in addition to our Demo.java, there are some project configuration files, also submitted.
Then click on Eclipse's window-show view to find Git repositories
Find Git on the left is our project, there are branches, working directory and other information, right-click Git Project-"show in the history can see the right side of our operation information, including just the action we submitted
Key Concepts:
The meaning of the ID in the right box: You see the right ID e414f3a is the commit ID (version number), and SVN is not the same, GIT's commit ID is not a ... Incrementing the number, but a SHA1 calculated by a very large number, in hexadecimal notation, and you see the commit ID and my affirmation is not the same, whichever is your own. Why does the commit ID need to be represented by such a large number of numbers? Because Git is a distributed version control system, we also want to study how many people work in the same repository, if we all use a three-to-one version ... As a version number, it must have been a conflict. Each time a new version is submitted, git actually automatically strings them into a timeline.
The meaning of the master in the right box: every commit, git strings them into a timeline, which is a branch of the line. As of now, there is only one time line, in Git, this branch is called the main branch, the Master branch.
The meaning of the head in the right box: git must know which version of the current version, in Git, the current version with Head, that is, the latest commit e414f3a
Now we are going to submit it again, this time we add a method get () to the demo file, and then the history box will show the submission, and head will point to the latest submission in time.
Now, we need to fall back to the first version when we imported Git, that is, fallback to version number E414F3A.
We can select the version we want to fallback directly in the history box, then right-reset-"hard, click OK, then our second commit version disappears, the Demo.java file also reverts to the first import appearance, the head pointer also returns."
What if we want to go back?
As long as the previously submitted versions have been recorded by Git, in the Git repositories box, right-click Project-"Show in-" git Reflog, git reflog the details of each of your actions
We want to go back to "second commit" version, only need to find the second commit version ID, is 95bc224, in the Git repositories box right-click Reset, enter the version number, you can.
Demo.java file again reverted to the appearance of the second submission, Liao Xuefeng Tutorial inside a chapter "work area and staging area" concept is very important, to understand the staging area, to understand the git a lot of operations in the end what to do.
Transferred from: http://m.blog.csdn.net/article/details?id=52739343
Eclipse Egit (version fallback)