.

iT邦幫忙

0

重新學JAVA-02-1-2 從GITHUB抓數據庫下來與更新

  • 分享至 

  • xImage
  •  

前面有提到如何在本地端將檔案push到Github上,今天來介紹如何從Github下載數據庫到電腦使用

先建立一個數據庫
https://ithelp.ithome.com.tw/upload/images/20250309/201346172GKYszPKQa.png

為數據庫命名、描述,這個數據庫預設是公開的(public),如果要不公開需要付費唷!
https://ithelp.ithome.com.tw/upload/images/20250309/20134617hrlEijr2pW.png

確認其他設定都沒問題的話就可以按下 create repository 這個綠色按鈕囉!
https://ithelp.ithome.com.tw/upload/images/20250309/20134617BvgMVhtX9j.png

完成後,會跳轉到一個頁面,上面會提示要怎麼使用,等一下將檔案傳送到Github時候還會用到,先不關掉
https://ithelp.ithome.com.tw/upload/images/20250309/20134617UiVN0IiQrH.png

回到git bash 視窗中,要利用上面的網址將數據庫抓下來
因為在repository上我命名為gitTest2,因此我先建立一個資料夾 運用:mkdir y 資料夾名稱(gitTest2)
https://ithelp.ithome.com.tw/upload/images/20250309/20134617CSyRxzfFuk.png

接著使用 git clone 指令,將剛剛建立好的數據庫網址貼上來
https://ithelp.ithome.com.tw/upload/images/20250309/201346171ZrZYhkSHE.png

完成之後呢會跑出一段話,因為剛剛建立的數據庫什麼都沒有,所以抓下來是空的
https://ithelp.ithome.com.tw/upload/images/20250309/20134617DNl63HzEo5.png

這時候到剛剛建立的資料夾gitTest2可以確認有沒有.git的透明資料夾
https://ithelp.ithome.com.tw/upload/images/20250309/20134617ZkoEufNeWo.png

使用 touch 指令建立檔案
https://ithelp.ithome.com.tw/upload/images/20250309/20134617LGV2cyVY9C.png

使用 git add . 指令將檔案加到目錄去
https://ithelp.ithome.com.tw/upload/images/20250309/20134617CzsrKRMKlk.png

使用 git commit -m '我是註解' 指令將剛剛的檔案添加註解
https://ithelp.ithome.com.tw/upload/images/20250309/20134617d4LVX9I6dm.png
https://ithelp.ithome.com.tw/upload/images/20250309/20134617bncRqREzkI.png

使用git push 指令將本地的資料送到遠端(Github)上
使用git push 指令時,會要求輸入帳號密碼後才會開始傳,因為要確保是不是本人~可以做設定,但目前要熟悉操作所以就先不提
https://ithelp.ithome.com.tw/upload/images/20250309/20134617gnodm82egs.png

這時候回到剛剛建立好repository的網頁,將網頁重新整理,就會看到更新上去的檔案(userController)囉!
https://ithelp.ithome.com.tw/upload/images/20250309/20134617iZK8pLQwaX.png

在重複剛剛的動作(新增檔案到推到遠端)一次吧
新增userService.java檔案
https://ithelp.ithome.com.tw/upload/images/20250309/20134617t01EnZHR5u.png

加到目錄
https://ithelp.ithome.com.tw/upload/images/20250309/201346170LCmzP5PBm.png

在這裡,我用git status 這個指令看一下檔案的狀態
https://ithelp.ithome.com.tw/upload/images/20250309/20134617X9Oifdp1if.png

在加入註解
https://ithelp.ithome.com.tw/upload/images/20250309/20134617IqZUWGU211.png

最後更新到遠端
https://ithelp.ithome.com.tw/upload/images/20250309/20134617xJgici5Z8F.png

把網頁重新整理,就看到剛剛更新的userService.java啦
https://ithelp.ithome.com.tw/upload/images/20250309/20134617iwqwyMPqfp.png


.
圖片
  直播研討會

尚未有邦友留言

立即登入留言