The use of Git and GitHub in Eclipse and Androidstudio

Source: Internet
Author: User

1.Eclipse use 1.1. Local project Create library and submit Remote Library

1. Install the Git plugin in ecliplse;

Ecliplse中插件安装地址:Egit - http://download.eclipse.org/egit/updates  

2. Create a blank library on GitHub that is the same as the local item to be uploaded;
3. Right-click->team->share project->git; in the local library project
4. Click "Use or create repository in parent folder of Project";
5. Then click "Create Repository" and click Finish;
6. Now that the local library is built, you need to submit the file to the local library first:
In the local project right-click->team->commit-> Select the file to be submitted and add comments, click Commit so that the local library submission has been completed;
7. Push the commit of the local library to the remote library:

1 Right-click Project->team->remote->push
2 fill in the URL of the GitHub project and fill in the user and password
3 Click Next
4 Select source Ref and add
5 Click Next if there are no conflicting files, tap finish
6push successful words will pop up pushed to ... dialog box.

1.2. Remote Library project acquisition and modification submission

1. Switch the eclipse view to Git repository;
2. Click Clone git repository:

Set git project location and user choose to use an SSH connection, there will be an exception if you use an SSH connection, this exception does not occur;

3. Select Branch Branch;
4. Select place in local directory;
5. The import was successful.

Use 2.1 in 2.Android Studio. Create a local library and share to GitHub
    • Mode 1:studio Interface

1. Configure the Git.exe path: setting->version control->git Set the click Test test, pop-up Version, indicating the success of the configuration;
2. Configure your GitHub account: Setting->version control->github;
3. Select the item you want to Share, select the menu bar->vcs->import into Versioncontrol->share project on Github;
4. Pop-up box set repository name and library description settings;
5. Select the file to commit to GitHub;
6. Select Commit and push.

    • Mode 2: Command form

1. Open git bash and go to the project directory to push;
2. Create an empty library on GitHub;
3. Enter the following command in Git bash;

1.git Init initializes a local library;
2.* set some files in. gitignore that do not require add and commit;
3.git Add. Add all files to the pending state;
4.git commit-m "Submit description" to submit the add file to the local library;
5.git Push-u Origin Master initial submission.

Git push origin master means uploading the local current branch code to the Master branch. Git push is to upload all local branch code to the remote corresponding branch

2.2.clone project on GitHub to local

1. Open git bash and go to the Save directory of the Clone project;
2. Enter the command: The SSH clone link on git clone +github;
3. If your Id_rsa file has a password, enter the password and start clone.

3.git using extra Tips 3.1. Resolve Push conflicts

In the case of collaborative development of multiple people, there is a conflict in the push of updates to the server, so the latest version of the server side and the local warehouse conflict need to be resolved before the push is taken. Pull is the server side of the update to the local warehouse to merge, resolve the merge conflict, you can successfully push to the server branch.

1.A修改了服务器文件1,并先push到了服务器;2.B也修改了服务器文件1,并pull来合并本地和远程仓库,文件有冲突,git会自行合并;3.合并的文件不能直接提交,右键冲突的文件->team->merge tool;4.选择用本地最新版本的文件和服务器做比较;5.修改冲突文件;6.冲突解决完毕后,右键文件Team->to index再次将文件加入索引并可以push到服务器;7.A此时可以pull服务器的文件到本地库,这就完成了一次两人协作开发。
3.2. Reset function

1.Soft:
The current branch is reset to the specified commit record location, and the index and working tree are unchanged;
2.Mixed:
The current branch is reset to the specified commit record location, the index is updated, and the working tree is unchanged;
3.Hard:
The current branch is reset to the specified commit record location, and the index and work tree are updated.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Use of git and GitHub in Eclipse and Androidstudio

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.