Eclipse Git、GitHub 快速使用手册

本文详细介绍如何在Eclipse中使用EGit插件进行Git仓库的管理,包括安装EGit、创建本地仓库、提交代码、推送至GitHub远程仓库、更新远程代码及检出maven和Android项目。
部署运行你感兴趣的模型镜像

一、安装EGit(更多使用方法请参考这里

Eclipse中打开Eclipse Marketplace搜索"EGit",安装好插件

二、创建本地仓库、提交(Commit)代码

选择项目并右键 > Share Project...


选择Git,然后Next,配置新仓库的路径。也可以勾选"User or create repository in parent folder of project"在当前项目中创建仓库


选择当前项目并右键 > Team > Commit...(执行Commit,会自动先执行Add to Index,省去一步操作)


点击Commit,项目将提交至本地仓库中

三、提交(Push)代码至远程仓库GitHub

登录GitHub.com,Create a New Repo,创建远程仓库


输入项目名称与描述,其它根据情况进行设置,完成后点击Create Repository


获取远程仓库地址,Copy下来以便后面使用(暂时使用HTTP协议,通常会使用SSH协议)


在Eclipse中打开Git Repository视图,配置远程仓库


配置URI信息,使用之前Copy下来的GitHub远程仓库地址


User、Password为GitHub.com的账号与密码


指定Push目录(规范),Push Ref Specifications


接下来提交(Push)项目至远程仓库


出现以下窗口提示,则说明Push成功



四、更新(fetch)远程代码至本地GitHub

fetch:是从远程获取最新版本到本地,不会自动merge

pull:是从远程获取最新版本并merge到本地仓库,pull=fetch+merge

从安全角度出发,fetch比pull更安全,因为我们可以先比较本地与远程的区别后,选择性的合并。

如pull时报错误:The current branch is not configured for pull No value for key branch.master...
则需要对Local Branches进行如下配置;

配置信息可通过Window > Preferences > Team > Git > Configuration > Repository Settings 进行查看或修改;


五、检出maven web项目远程版本库到本地

检出远程版本库,首先需要克隆(Clone)远程库到本地
*或者直接使用Import > Git > Project from git > URL 方式直接导入


配置远程仓库信息

配置克隆下来的远程分支与仓库存放位置

接下来,开始从克隆的远程仓库检出项目,选择Import Project...

由于项目缺少eclipse本地配置信息(如:.project等文件),只能在导入时选择Import as general project,再将项目转换成需要的项目类型

首先将项目转换为Dynamic Web Project项目

配置Project Facets

完成后,再将项目转换为maven项目

编辑项目Build Path,增加Source Folder;

为新建的Source Folder 指定Output folder,注意勾选Allow output folders for source folders;

编辑Libraries,修改JRE System Library;

修改Java Compiler;

修改项目的发布规则,如下图;

最后删除多余文件,最终结构如下图;


六、检出Android项目远程版本库到本地

检出远程版本库,首先需要克隆(Clone)远程库到本地


配置远程仓库信息,User、Password为GitHub.com的账号与密码


配置克隆下来的远程分支与仓库存放位置


接下来,开始从克隆的远程仓库检出项目,选择Import Project...


选择Use the New Project wizard...


根据项目情况进行选择,这里选择Android Project from Existing Code...


选择克隆仓库中的代码,修改项目名称,勾选将项目Copy到workspace


检出项目完成


注意:以上方式检出项目后,会存在两个本地仓库,上图第一个为直接克隆的远程仓库,第二个相当于又复制出来了一个克隆仓库,检出完成后,避免重复可删除第一个仓库,留下需要实际操作的工作空间中的这个库。也可以在上一步操作中,不勾选“Copy Projects Inot Workspace”则不会出现重复的仓库,但项目文件不在默认的工作空间中。(如果将远程仓库直接克隆到工作空间中,再通过以上操作检出项目,因为项目重名,会出现“invalid project description”错误)

更多使用方法(冲突解决等)请参考这里

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

Eclipse Git用户指南 目录 1 Getting Started 1.1 Overview 1.2 Basic Tutorial: Adding a project to version control 1.2.1 Configuration 1.2.1.1 Identifying yourself 1.2.1.2 Setting up the Home Directory on Windows 1.2.1.3 Pointing out the System wide configuration 1.2.2 Create Repository 1.2.3 Track Changes 1.2.4 Inspect History 1.3 GitHub Tutorial 1.3.1 Create Local Repository 1.3.2 Create Repository at GitHub 1.3.3 Eclipse SSH Configuration 1.3.4 Push Upstream 1.4 EclipseCon 2012 Git Tutorial 2 Concepts 2.1 Repository 2.2 Index 2.3 Branches 2.3.1 Local Branches 2.3.2 Remote Tracking Branches 2.4 Working Directory 2.5 Recording Changes in the Repository 3 Tasks 3.1 Creating Repositories 3.1.1 Considerations for Git Repositories to be used in Eclipse 3.1.1.1 The short story 3.1.1.2 The longer story 3.1.1.2.1 Eclipse Workspace and Repository working directory 3.1.1.2.2 Implications 3.1.2 Creating a new empty Git Repository 3.1.3 Creating a Git Repository for multiple Projects 3.2 Starting from existing Git Repositories 3.2.1 Starting the import wizard 3.2.2 Cloning or adding Repositories 3.2.2.1 Cloning a Repository 3.2.2.2 Adding a Repository 3.2.3 Selecting a Repository from the List 3.2.4 Importing projects 3.2.5 Wizard for project import 3.2.5.1 Import Existing Projects 3.2.5.1.1 Limiting the Scope for Project Import 3.2.5.2 Use the New Projects Wizard 3.2.5.3 Import as General Project 3.3 Working with remote Repositories 3.3.1 Cloning Remote Repositories 3.3.1.1 Repository Selection 3.3.1.2 Branch Selection 3.3.1.3 Local Destination 3.3.1.4 Cloning from specific locations 3.3.2 Pushing to other Repositories 3.3.2.1 Pushing to upstream 3.3.2.1.1 Configuring upstream push 3.3.2.2 Direct Push 3.3.2.3 Push Wizard 3.3.2.3.1 Push URI 3.3.2.3.2 Push Ref Specifications 3.3.2.3.3 Delete Ref Specifications 3.3.2.3.4 Conflicting Push Ref Specifications 3.3.2.3.5 Push Confirmation 3.3.2.3.6 Push Result Report 3.3.3 Fetching from other Repositories 3.3.3.1 Fetching from upstream 3.3.3.1.1 Configuring fetch from upstream 3.3.3.2 Direct Fetch 3.3.3.3 Fetch Wizard 3.3.3.3.1 Fetch Ref Specifications 3.3.3.3.2 Fetch Result Report 3.3.4 Pulling New Changes from Upstream Branch 3.4 Working with Gerrit 3.4.1 Enabling Gerrit for a repository 3.4.2 Pushing a change to a Gerrit Code Review Server 3.4.3 Fetching a change from a Gerrit Code Review Server 3.5 Inspecting the state of the Repository 3.5.1 Label Decorations 3.5.1.1 Text Decorations 3.5.1.2 Icon Decorations 3.5.2 Commit Dialog 3.5.3 Comparing Content 3.5.3.1 Compare editor and Synchronize View 3.5.3.2 Compare working tree with last commit 3.5.3.3 Comparing Working Tree with Index 3.5.3.4 Comparing Working Tree with a branch, a tag or a reference 3.5.3.5 Comparing Working Tree with Any Commit 3.5.3.5.1 From the project explorer: 3.5.3.5.2 From the history view (files only): 3.5.3.6 Comparing Two Commits 3.5.3.7 Comparing Index with HEAD or Any Other Commit 3.5.4 Comparing with Branches (Synchronize) 3.5.5 Quickdiff 3.5.6 Inspecting Commits 3.5.6.1 View Diff for a Commit 3.5.6.2 Showing the contents of a Commit 3.6 Committing Changes 3.6.1 Modifying the content 3.6.2 Committing 3.6.2.1 Committing with the Staging View 3.6.2.2 Committing using Commit Dialog 3.6.2.3 Commit Message 3.6.2.4 Amending Commits 3.7 Reverting Changes 3.7.1 Reverting changes in the working tree 3.7.1.1 Replace with File in Git Index 3.7.1.2 Replace with HEAD 3.7.1.3 Replace with Branch, Tag or Reference 3.7.1.4 Replace with Commit 3.7.1.5 Replace with Previous Revision 3.7.2 Revert using quickdiff 3.7.3 Reverting changes introduced by a specific commit 3.7.4 Resetting your current HEAD 3.7.4.1 Reset to specific branch or tag 3.7.4.2 Reset to a specific commit 3.7.4.3 Revert all local and staged changes 3.8 Branching 3.8.1 General remarks about branches 3.8.1.1 Upstream configuration 3.8.2 Checking out an existing Branch 3.8.2.1 From the team menu on a project node: 3.8.2.2 From the Git Repositories View 3.8.2.3 From the History View 3.8.3 Creating a New Local Branch 3.8.3.1 From the team menu 3.8.3.2 From the Repositories View 3.8.3.3 From the History View 3.8.4 Renaming an Existing Branch 3.8.4.1 From the Team menu on a Project node 3.8.4.2 From the Repositories View 3.8.4.3 From the History View 3.8.5 Deleting a Branch 3.8.5.1 From the Team Menu on a Project node 3.8.5.2 From the Repositories View 3.8.5.3 From the History View 3.8.6 Branch Creation Dialog 3.8.7 Configure Branch Dialog 3.9 Merging 3.9.1 Merging a branch or a tag into the current branch 3.9.1.1 Starting merge from the History View 3.9.1.2 Starting merge from the Team menu 3.9.1.3 Starting merge from the Git Repositories View 3.9.1.4 Merge options 3.9.1.5 Possible merge results 3.9.1.5.1 Merge Result dialog 3.9.2 Resolving a merge conflict 3.9.2.1 Using Merge Tool 3.9.2.2 Manual conflict resolution 3.9.2.3 Finding conflicting files 3.9.2.4 Editing conflicting files 3.9.2.5 Adding conflict resolution to the git index 3.9.2.6 Committing a merge 3.9.3 Aborting Merge 3.10 Rebasing 3.10.1 Rebase Introduction 3.10.2 Rebase, A Simple Example 3.10.3 The Real World: Rebase Conflicts 3.10.4 Starting Rebase 3.10.5 Rebase Confirmation Dialog 3.10.6 Rebase Conflicts 3.10.7 Aborting Rebase 3.11 Interactive Rebase 3.11.1 Synopsis 3.11.2 Starting interactive rebase 3.11.3 Planning rebase 3.11.4 Executing interactive rebase 3.11.5 Safety Instructions 3.11.6 Rebase with auto-stashing 3.12 Cherry Picking 3.12.1 Cherry-pick Introduction 3.12.2 Cherry-pick Example 3.13 Tagging 3.13.1 Creating a Tag 3.13.2 Replacing an Existing Tag 3.13.3 Deletion of tags 3.13.4 Light-weight and Signed Tags 3.14 Patches 3.14.1 Creating Patches 3.14.1.1 Create a Patch from a Commit 3.14.1.2 Patch Wizard 3.14.2 Applying Patches 3.15 Managing Repositories 3.15.1 Adding Repositories to the Git Repositories View 3.15.1.1 Adding a Repository manually 3.15.1.2 Cloning a Repository 3.15.1.3 Creating a Repository 3.15.1.4 Adding a Repository using Copy and Paste 3.15.2 Removing Repositories 3.15.2.1 Removing a Repository from the Repositories View 3.15.2.2 Deleting a Repository 3.15.3 Structure of the Git Repositories View 3.15.4 Functions of the Git Repositories View 3.15.4.1 Project Import 3.15.4.2 Branch and Tag Support 3.15.4.2.1 Check-out of Branches and Tags 3.15.4.2.2 Creation and Deletion of Branches 3.15.4.2.3 Rebasing 3.15.4.2.4 Merging a Branch or a Tag 3.15.4.2.5 Synchronizing with a Branch or a Tag 3.15.4.2.6 Determining the Checked-out Branch 3.15.4.2.7 Resetting to a Branch or a Tag 3.15.4.2.8 "Detached" HEAD 3.15.4.3 Inspecting References 3.15.4.4 Browsing the Working Directory 3.15.4.5 Repository Configuration 3.15.4.6 Remote Repositories 3.15.4.6.1 Direct Fetch and Push Support 3.15.4.6.2 Adding a Remote Configuration 3.15.4.6.3 Changing Remote Configurations 3.15.4.6.4 Gerrit Configuration 3.15.5 Refresh 3.15.6 Link with Selection 3.15.7 Link with Editor 3.15.8 Hierarchical Branch Layout 3.15.9 Bare Repositories 3.15.10 Removing Repositories from the Git Repositories View 3.15.11 Showing Repository in Related Views 3.15.11.1 Show in History 3.15.11.2 Show in Reflog 3.15.11.3 Show in Properties 3.16 Working with Tasks 3.16.1 Installation 3.16.2 Commit Message Template 3.17 Viewing Commits 3.17.1 Tagging a commit 3.17.2 Creating a branch from a commit 3.17.3 Checking out a commit 3.17.4 Cherry picking a commit 3.17.5 Opening the commit viewer 3.18 Searching for commits 3.18.1 Git Search page 3.18.2 Browsing Search Results 3.18.3 Launching Git Search 3.18.4 Open commit dialog 3.19 Finding the author of each line in a file 3.20 Working with Submodules 3.20.1 Cloning Repositories with Submodules 3.20.2 Browsing Submodules 3.20.3 Adding a Submodule 3.20.4 Updating Submodules 3.21 Team Project Sets 3.21.1 Import 3.21.2 Export 3.21.3 Format 4 Reference 4.1 Menus 4.1.1 Project Context Menu 4.1.2 Resource Context Menu 4.1.3 Repositories View Menus 4.1.4 History View Menus 4.1.5 Git Workbench Toolbar and Git Workbench Menu 4.1.6 Menu Actions 4.2 Git Perspective and Views 4.2.1 Git Perspective 4.2.2 Git Repositories View 4.2.3 History View 4.2.3.1 Overview 4.2.3.2 Opening the History View 4.2.3.3 Organization of the History View 4.2.3.4 Using the History View 4.2.3.4.1 Inspecting the Commit Graph 4.2.3.4.2 Displaying and Comparing versions of a File 4.2.3.4.3 Working with the Filter Settings 4.2.3.5 Toolbar actions 4.2.3.5.1 Find 4.2.3.5.2 Filter settings 4.2.3.5.3 Compare Mode 4.2.3.5.4 All Branches 4.2.3.6 View Menu actions 4.2.3.6.1 Configuring the View 4.2.3.7 Context Menu actions 4.2.3.7.1 Compare with working tree 4.2.3.7.2 Compare with each other 4.2.3.7.3 Open 4.2.3.7.4 Checkout 4.2.3.7.5 Create Branch... 4.2.3.7.6 Delete Branch 4.2.3.7.7 Create Tag... 4.2.3.7.8 Create Patch... 4.2.3.7.9 Cherry Pick 4.2.3.7.10 Revert Commit 4.2.3.7.11 Merge 4.2.3.7.12 Rebase on top of 4.2.3.7.13 Reset > Soft/Mixed/Hard 4.2.3.7.14 Quickdiff > Reset Quickdiff Basline to HEAD 4.2.3.7.15 Quickdiff > Reset Quickdiff Basline to first parent of HEAD 4.2.3.7.16 Quickdiff > Set as Baseline 4.2.3.7.17 Copy 4.2.3.7.18 Show Revision Comment 4.2.3.7.19 Show Revision Details 4.2.3.7.20 Wrap Comments 4.2.3.7.21 Fill Paragraphs 4.2.3.8 Drag and Drop Support 4.2.3.9 Working with the Revision Details Area 4.2.4 Synchronize View 4.2.4.1 Synchronization State 4.2.4.2 Mode 4.2.4.3 Models 4.2.4.4 Navigation 4.2.5 Git Tree Compare View 4.2.6 Git Staging View 4.2.6.1 Partial Staging 4.2.7 Git Reflog View 4.3 Git URLs 4.4 Git References 4.5 Refspecs 4.5.1 Push Refspecs 4.5.2 Fetch Refspecs 4.6 Remotes 4.7 Git Ignore 4.8 Git Fetch Factory for PDE Build
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值