1 安裝git
已安裝,有需要搜其他教程
2 配置git
2.1 爲IDEA指定git路徑
settings->Version Control->Git->Path to Git executable: 設置爲本地安裝的git.exe
2.2設置github賬號
settings->Version Control->GitHub->Create API Token
報錯: invaild authentic data
重新關掉打開或者軟件重啓
3 idea上建項目push到GitHub
3.1 創建repository得到地址https://github.com/jayryan2088/ideagit
3.2 在本地創建一個項目
接着在本地創建一個項目ideagit,並且新建一個Java類
3.3 建立本地倉庫並加入project
VCS->import into Version Control->Create Git Repository->e:\project\hiworld-OK
右鍵項目名->Git->Add
3.4 提交項目
右鍵項目名->Git->Commit Directory之後彈出窗口,在Commit Message 輸入 test, 然後點擊 Commit And Push
報錯:提交代碼的時候彈框提示git user name is not defined
解決:自己寫本地用戶名郵箱就行
報錯:不能完整提交changes
解決:github上刪了本地重新建一個
3.5push
點擊Define remote,並輸入repository地址
CONG! SUCCESS!!!
4 從github上獲取項目
4.1 get
VCS->Get from Version Control->GitHub
4.2輸入項目參數
Git Repositor URL:https://github.com/jayryan2088/ideagit
Parent Directory: D
Directory Name: ideagit
然後點擊 Clone
成功下到本地!!!
5 在idea上提交project
5.1 提交
修改本地項目,提交改動
右鍵項目名->Git->Commit Directory之後彈出窗口,在Commit Message 輸入 test, 然後點擊 Commit And Push
這些按鈕很方便
5.2報錯
今天提交idea上的代碼到GitHub,提交過程已經完成,
在版本控制的Log中可以看到,已經將這一部分都提交更新了
但是GitHub上並沒有找到提交的代碼
怎麼辦呢?
是因爲剛剛走的過程中,其實還是沒有走完,只是將Idea上的代碼提交到了Git本地倉庫,並沒有將Git倉庫中的代碼提交到GitHub網站上
所以,還是需要將Git上的代碼提交到GitHub上!!
右鍵項目名->Git->repository-> Push
成功解決,github上有了