iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 8
0
自我挑戰組

網頁學習日誌系列 第 8

Git : 上傳資料到Github

上傳到遠端資料庫

因為之前所做的都是在本地端資料庫,要上傳到Github連線遠端的話,必須要下載遠端資料庫的git檔案,
會使用 複製遠端資料庫 的語法

//複製遠端資料庫
git clone 遠端資料庫網址
  1. 打開GitBash ,指向git_test資料夾,之後輸入上面的git clone語法

如下圖,接下來進入圈選處的git_test,剪下隱藏資料夾 「.git」,貼到上層的git_test

https://ithelp.ithome.com.tw/upload/images/20200411/20107321MWcc4JCubn.png

https://ithelp.ithome.com.tw/upload/images/20200411/201073219KtTq049RD.png

https://ithelp.ithome.com.tw/upload/images/20200411/20107321QzKNGVXm79.png

再把上圖的4個檔案中的git_test刪掉之後,打開GitBash指向到桌面的git_test資料夾可發現
後面多出master,這個是遠端分支名稱。

https://ithelp.ithome.com.tw/upload/images/20200411/20107321QebKIWJB1Z.png

  1. 確認遠端資料庫名稱

先確認資料庫名稱,語法如下:

//查詢遠端數據庫
git remote

可得到origin的名稱

https://ithelp.ithome.com.tw/upload/images/20200411/20107321yGVr91zJoV.png

3.確認檔案是否全都加入索引和git log紀錄,如果沒有就不能上傳到Github

//確認狀態
git status
//加入索引
git add.
//加入commit紀錄
git commit -m '更新訊息'
//顯示歷史紀錄
git log

https://ithelp.ithome.com.tw/upload/images/20200411/20107321q1tgUgjIhF.png

4.上傳檔案

語法如下

//將本地分支推送到遠端分支
git push 遠端資料庫名稱 遠端分支名稱

資料庫名稱:origin
遠端分支名稱:master

所以輸入

git push origin master

跳出輸入github帳號選項和密碼視窗

https://ithelp.ithome.com.tw/upload/images/20200411/20107321v6dlHKoIw9.png


產生網址

回到Github資料庫git_test,可看到網頁檔案已經上傳,而且也有commit紀錄,接著進入Settings

https://ithelp.ithome.com.tw/upload/images/20200411/20107321olXlfF9Rhs.png

尋找GitHub Pages,Source選項改master branch,按下sava儲存,則會出現網址可瀏覽網頁,

https://ithelp.ithome.com.tw/upload/images/20200411/20107321g1hk6eiBku.png


刪除資料庫

如果要刪除資料庫(git_test)可選下圖綠色圈選處Delete this repository

https://ithelp.ithome.com.tw/upload/images/20200411/20107321JMWxxxThCF.png


上一篇
Git : Github簡介和註冊
下一篇
RWD : @media斷點
系列文
網頁學習日誌30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言