輸入你要的Project Name即可,在這用的是gitdemo

Create repository成功後,github會提供repository存取的uri,你可以使用ssh或http,也可以給他人readonly的uri,接下來的操作我選擇使用ssh的uri進行clone與push

(2) Import git repository and create eclipse project
要使用import的方式才能選到Git Repository相關的操作,為什麼用new project的方式就不行,這...

選Project from Git

直接按下Clone即可

填入ssh要用的uri,protocol改選為git+ssh,user就一定要填git


輸入Local端git repository存放的位置,基本上就是你eclipse project要放的目錄,remote name雖然可以改,但非常不建議

Eclipse 取得git repository的資訊後就開始要求eclipse project所需要的資料了,所以接下來就是建立eclipse project
先選取要用的git repository

因為git repository裡面沒有任何已存在的eclipse project,所以在Method for project creation就選第二項,至於sharing project的部份,也請選取第二項。

接下來就是真的create eclipse project了,在這我用的是create Maven project, 接下來填maven group id , artifact id的部份就不贄述了

create project完成後,wizard會要求選取要share的project與git repository,也就是建立project 與 git repository的關連

(3) First Commit
接下來就進行第一次的commit,
Git的操作是依git add -> git commit -> git push的順序來進行的。
所以先將project基本的檔案加進project裡,也許是些configuration files或是base classes
看起來似乎很不錯,但在目前這階段,你會發現你要經由egit 執行add file to staged都不成功,
這是有原因的,晚些再來看看怎麼解決吧,先利用egit 做commit的處理吧
選取team, 再選commit

再選取要commit檔案,eclipse project相關的檔案記得也要勾選以進行commit,否則以後其他人clone 這個repository時會無法直接使用eclipse產生project

再來如果你想進行push,將剛才的改變push到github上,如果不選擇Custom URI而使用當前建好的origin remote會發生錯誤,這部份就要靠下一步解決囉
(4) Update Git Remote Configuration
先切換View到Git Repositories看看EGit為我們建立的Remote

馬上會發發現一件事,這個remote沒有push的uri

解決的方式就把它加上去吧,點選remote按右鍵,選Create Push

然後又會出現要輸入github repository uri的畫面(這不是鬼打牆!

再來選取要Push的branch

記得要按下Add all branches spec
按下finish後再確認origin這個remote的properties,就會發現Push URI出現囉

這時再進行Push的操作就ok囉,下面就是Push的最後確認,按下Finish就會真的送到Github上囉

最後再去檢查Github Repository,看到檔案都出現在Repository應該就沒問題了

沒有留言:
張貼留言