# Eclipse + Github 設定 使用Eclipse上傳/下載Git項目 前提: + Eclipse已安裝EGit插件 + 已擁有GitLab/GitHub賬號 SSH方式 配置SSH授權 1. 本地生成授權Key Eclipse,選擇菜單: 2. 遠程托管配置本地授權的Public Key 進入GitLab管理首頁, 在 ... 中輸入 ## 使用Eclipse上傳/下載Git項目 ### 前提: * Eclipse已安裝EGit插件 * 已擁有GitLab / GitHub / 其它Git托管服務賬號 ### SSH方式 #### 配置 ##### 配置Git信息 * 配置用戶信息 * Eclipse,選擇菜單:`Preferences > Team > Git > Configuration > User Settings > Add Entry..` * Key: user.name, Value: username * Key: user.email, Value: username@A702.HRGY 可自定義帶個人特征的用戶信息,與Git托管服務賬號無關 ##### 配置SSH授權 1. 本地生成授權Key Eclipse,選擇菜單: `Window > Preferences > General > Network Connections > SSH2`,進入SSH2對話框 * 配置SSH Home路徑 選擇 `General > SSH2 home`(輸入ssh信息保存路徑:` I:\WorkSpace\CODE\git\.ssh) > Apply` * 生成授權Key 選擇 `Key Management > Generate RSA key.. > Passphrase(輸入密碼,將在使用密鑰時使用) > Save Private Key.. > Apply` * 配置Private Key 選擇 `General > Private Key(選擇剛生成的私匙路徑: I:\WorkSpace\CODE\git\.ssh\id_rsa) > Apply` 2. 遠程托管配置本地授權的Public Key 進入GitLab管理首頁,`Profile Settings > SSH keys > Add an SSH key` 在 Key 中輸入剛纔生成的Public Key ### 上傳項目 #### Commit至本地Git倉庫 1. 創建本地Git倉庫 右鍵工程,選擇菜單: `Team > Share Project > Git 在Configure Git Repository`對話框中,依次選擇: `Use or create repository in parent folder of project > 勾選Project列表 > Create Repository > Finish` 2. Commit至本地Git倉庫 右鍵工程,選擇菜單:`Team > Commit` 在Commit Changes對話框中,Commit message填:初始導入;勾選Files列表中要提交的文件。 點擊commit進行提交 #### Push至遠程Git倉庫 1. 創建Git遠程托管項目 在GitLab管理首頁依次選擇: `Projects > New Project` 在 Project path 填項目名稱,然後選擇 `Create project`。 創建成功,會顯示項目相關信息及Push方法。其中有SSH連接,如:`git@gitlab.com:user/project.git` 2. Push至遠程Git倉庫 右鍵工程,選擇菜單: `Team > Push Branch 'master'.. (或Team > Remote > Push..)` 在 `Push Branch master` 對話框中,`Location > URI` 填寫1. 創建Git遠程托管項目得到的SSH連接:`git@gitlab.com:user/project.git` 點擊 `Next > Next > Finish` 如果在生成SSH授權Key時,有輸入Passphrase密碼值,則此過程會彈出提示要求輸入 開始 `Pushing to remote repositories`,等待上傳 點擊OK完成 ### 下載項目 * Eclipse,選擇菜單: `File > Import.. > Git > Projects from Git > Clone URI`, 在`Import Projects from Git` 對話框中,`Location > URI` 填寫Git托管項目的SSH連接:`git@gitlab.com:user/project.git`,點擊 `Next` 如果在生成SSH授權Key時,有輸入Passphrase密碼值,則此過程會彈出提示要求輸入 * 分支選擇:選擇 `master`,點擊 `Next` * 配置本地存儲路徑:選好存儲目錄,點擊 `Next` * 選擇一個用來導入項目的嚮導:選擇 `Import existing Eclipse projects`,點擊 `Next` * 導入項目:從 `Projects` 列表中選擇要導入的項目,點擊 `Finish` ### 使用個人令牌 Personal access token (GitHub specific) 1. Go to your GitHub account to `Settings > Developer settings > Personal access tokens` website: 1. Click the `Generate new token` button in the upper right * Enter a `Note`, e.g. GitHub repo token * Choose `Expiration`, e.g. No expiration * Tick the checkbox `repo` 2. Click the `Generate token` button at the bottom 3. `Copy` the generated `token to the clipboard` 2. In Eclipse, in the `Git Repositories` view: 1. `Right-click` the `Remotes` sub-node for GitHub (`origin` or the name you have chosen when you have cloned the repository) and choose `Configure Push`... 2. Click the `Change...` button to change the URI in the upper right 3. `Replace the password with` with the copied generated GitHub `token` 4. Click `Finish` and `Save` to apply the changes 參考 http://www.zendei.com/article/9843.html http://www.tuicool.com/articles/Ar6rMfm http://wiki.eclipse.org/EGit/User_Guide http://yufenfei.iteye.com/blog/1750124 http://blog.csdn.net/hil2000/article/details/8566456 http://www.cnblogs.com/zhxiaomiao/archive/2013/05/16/3081148.html http://www.cnblogs.com/yejiurui/archive/2013/07/29/3223153.html https://stackoverflow.com/questions/68790276/pushing-from-eclipse-to-my-github-repository-via-https-stopped-working-git-rec ###### tags: `Eclipse`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up