Use of git/GitHub and integration with eclipse

Source: Internet
Author: User
Git Introduction

Git is a free, distributed version control tool, or a tool that emphasizes high speed.Source codeManagement tools. Each git working directory is completely independent.CodeDatabase, with complete history and version tracking capabilities, independent of the network and central server.

When managing a project, git has three local work areas: git's local data directory, working directory, and temporary storage area. As shown in:

Therefore, for any file, there are only three States in git: committed, modified, and staged ).

Install and configure git terminal run:
 
Sudo apt-Get install git Git-core
First go to The https://github.com/register an account, of course, is the free and opensource user. Create a git directory under the root directory.
 
Mkdir ~ /Git

Initialize two parameters:

 
Git config -- global user. Name = "username" Git config -- global user. Email = "***@*****"

Because the local machine is linked to GitHub through SSH, create an SSH key first. Check whether the local machine has an SSH key.

 
Cd ~ /. SSH

If no file or directory is displayed, it indicates that the local machine has not been created. Continue to execute

 
Ssh-keygen-t rsa-c "your_email@example.com"

All the way to enter, the. Ssh folder will be produced under the root directory (hide, press Ctrl + H to view the hidden folder), which contains the generated key file. Use gedit to open ~ /. Ssh/GitHub. Pub, copy the file content to the clipboard, (it is best to use gedit, other tools may have line breaks and spaces) return to the GitHub page, click
Acount setting,
Point
SSH keys,The title can be obtained at will. The key sticks the content of the copied Public Key to the point.
Add. Terminal test:

 
Ssh-T git@github.com

The result of a successful connection is as follows:

 
Agent admitted failure to sign using the key. Permission denied (publickey ).

Run

 
Ssh-add

Then the connection is complete.

One of the simplest ways to use git is to download others' open-source projects from GitHub. Open an open source project page and click the zip package in the upper left corner to download the project. It is more convenient to run commands on the terminal to download the source code. Terminal operation:
 
Git clone https://github.com/SimonVT/android-menudrawer.git

The entire project is automatically downloaded to the current directory. The next step is to share your project with GitHub and implement version control. First, create a project on GitHub. On the personal homepage, click New on the responsitories tab to enter some information. Click Create respository GitHub to create a project. Next, download the project and configuration file from the server to your local device. Terminal operation:

 
Mkdir ~ /Git/reposcd ~ /Git/reposgit clone git@github.com: ***/***. Git

After the execution is complete, the GitHub project is copied in the repos folder. Local Project editing. For example, after adding a file, you can use the following command to update the project.

 
Git add. // Add added and modified files to the temporary storage area, do not process the deleted file git status // compare the changes between the local data directory and the temporary storage area git commit-M "Commit directions ctions" // mention the code to the local data directory and add the submission instructions

It is possible that you and others change to the same file, so the conflict is inevitable. after submitting the file, you will get the code again, and the file with the code conflict will be prompted, what we need to do is to handle these conflicts and submit them again:

Git pull // update the code as prompted. modify the code in the conflicting file git Add. Git commit-M "Commit directions ctions"
After completing the preceding steps, you need to synchronize the version database data of the local data directory to the GitHub server.
 
Git push

After the submission is complete, refresh the GitHub page and find that the file has been updated. Integrate git in eclipse

First install the GIT plug-in. In eclispe, help-> install new software. Enter the address

Http://download.eclipse.org/egit/updates

Next, install the plug-in. Create a project in eclipse. Right-click the project and choose team> share project> git> next. Select use or create repository in parent folder of project, for example, click Finish. After the project folder is executed, A. Git folder is created and the repository is created. Because there are some files in the project that do not need to be uploaded, such as the bin folder, you need to set them in the project. Expand the corresponding project. A small arrow indicates the directory to be uploaded to the server. Right-click the directory you do not want to upload and choose team> ignoe. The directory will be ignored. Next, run the commit code to the local machine. Right-click the project and choose team> commit. Select the file to be commit, Click Commit, and the code will be uploaded to the local server. Next, upload the code to the GitHub server. Enter the project folder in the command line and run

Git remote add origin https://github.com/SilangQuan/LinearCompiler.git

Run again

 
Git push-F

After successful execution, you can view the GitHub project homepage and find that the file has been uploaded. After modifying the project code in eclipse, commit and right-click team-> push on the project to submit the code. After being uploaded to GitHub, other members of the team can extract the project through eclipse-> file-> Import-> project from Git-> Uri. During team development, the latest code is usually fecth before the start of a new day. Right-click the project and choose "team"> "Fetch". Then, execute ">" team ">" merge. "The New file on the server will be added. Reference: git/GitHub easy to use-http://www.cnblogs.com/fnng/archive/2012/01/07/2315685.html
Git reference manual-http://gitref.cyj.me/zh/index.html
Egit/User Guide-http://wiki.eclipse.org/EGit/User_Guide

 

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.