iT邦幫忙

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

網頁學習日誌系列 第 5

Git : 基礎操作-新增檔案和資料夾

以前不懂git時候,只會把靜態網頁放在google硬碟並開放共用給外界瀏覽,後來學到git並上傳到github才知道除了放網頁,另外有編輯紀錄(commits),可與團隊共同編輯並能清楚釐清責任歸屬。

git聽起來很高深,
實際上如果有在windos利用DOSBox玩過金庸群俠傳(野球拳最高!!!)的人

https://ithelp.ithome.com.tw/upload/images/20200411/20107321VLniL6pxvD.jpg

其中有個指令 輸入cd+空白鍵+legend接著是play,

玩過再使用git會覺得很親切啊~~!!

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

cd legend 就是進入該資料夾(legend),如果你要到點選進入資料夾就輸入 cd 資料夾名稱,後面的play為遊戲啟動的檔名。

不過不管是git 還是dosBox 輸入上面一定要到該資料夾的上層,在上面案例中也就是c槽,他才會正確執行。

到c槽方法:

輸入 cd + 空白鍵 + c: 輸入完按enter

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

後面出現 /c 就表示進入c槽了

現在把上面的指令套在git,首先到官網下載(https://git-scm.com/)

看到右下方的download點擊下載,官網會自動辨識電腦是windows 還是 mac,會出現相對應的載點,所以只要點擊下載就可以了

https://ithelp.ithome.com.tw/upload/images/20200411/201073212XRIzuWvFd.png

開啟資料夾,執行Git Bash (mac 資料夾執行 「終端機」的檔案 )

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

利用git bash 新增檔案和資料夾

1.先在桌面新增資料夾git_test
2.在git Bash 找到 git_test

直接輸入 cd+空白鍵
左鍵拖曳資料夾git_test 到git Bash 裡的 cd 空白鍵 那一行並放開

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

結果如下:
https://ithelp.ithome.com.tw/upload/images/20200411/20107321RYhLRJTSKr.png

按enter 就進入資料夾了

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

3.新增index.html
輸入

    touch index.html

輸入後,資料夾出現index.html

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

  1. 新增css資料夾
    輸入
    mkdir css

輸入後,資料夾出現css 資料夾

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

進入css資料夾則是直接輸入cd +空白鍵 +css

    cd css

結果如下圖

https://ithelp.ithome.com.tw/upload/images/20200411/201073215QmmNSX1Jy.png

回上一層就輸入cd+空白鍵+ ..

    cd ..

結果如下圖

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

想知道所在的git_test的資料夾有哪些資料夾和檔案,可以輸入 ls

    ls

下圖可看到他只會顯示git_test資料夾中有那些檔案和資料夾

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

總結目前的指令如下:

移動路徑 cd+空白鍵+路徑
回上一層 cd+空白鍵+..
列出所在資料夾的檔案 ls
新增資料夾 mkdir+空白鍵+資料夾名稱
新增檔案 touch+空白鍵+檔案名稱

上一篇
CSS : 網頁排版要注意的Box Model(盒模型)
下一篇
Git : Git config和本地數據庫
系列文
網頁學習日誌30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言