天天看點

Eclipse中git插件的使用

1.建立maven工程,把工程初始化本地庫

工程–>右鍵–>Team–>Share Project–>Git

Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用

2.設定本地庫範圍簽名

preferences–>team–>git–>configuration–>add entry

Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用

項目–>右鍵–>Team–>Commit

Eclipse中git插件的使用

可以發現Unstaged changes中有許多Eclipse中的特定檔案。

.settings、.classpath、.project是Eclipse管理項目的檔案,與開發沒有直接關系,最好不要在git中追蹤(可能協同開發中用的版本不一樣,相關特定檔案可能不同,如果這些檔案加入版本控制,那麼開發時很可能需要為了這些檔案解決沖突),把它們忽略。

3.忽略Eclipse中的特定檔案

在C:/User/Administrator目錄下建立Java.gitignore.txt檔案,因為.gitconfig檔案在此目錄下。

Eclipse中git插件的使用

打開https://github.com/github/gitignore,找到Java.gitignore,複制裡面的内容,粘貼到自己建立的Java.gitignore中。

打開.gitconfig檔案,将[core] excludesfile = C:/Users/Administrator/Java.gitignore

複制進去就可以了,注意必須使用"/"。

Eclipse中git插件的使用

4.Eclipse中本地庫操作

工程–>右鍵–>team–>commit

Eclipse中git插件的使用

5.将Eclispe上的工程推送到github上

在github上建立一個遠端庫

Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用

工程–>右鍵–>team–>remote–>push

Eclipse中git插件的使用
Eclipse中git插件的使用

github上就可以檢視上傳的項目了

Eclipse中git插件的使用

6.将github中的工程克隆到Eclipse

import—>git—>projects from git

Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用
Eclipse中git插件的使用

在Eclipse的左側就可以看到下載下傳的項目,這并不是一個标準的maven項目,需要轉換。

Eclipse中git插件的使用

接下來,将其轉成一個maven項目

項目–>右鍵–>Configure—>convert to maven project,就可以轉成maven項目

轉換後的項目如下:

Eclipse中git插件的使用

github上的工程克隆到Eclipse結束