需求軟體:Git (Windows/Mac)
圖型操作軟體:Fork (Windows/Mac)
本頁面目錄:
初始指令
常用操作指令
版本控制指令
雲端儲存Github相關指令
初始指令
$ git version
確認Git安裝成功 / 確認Git版本
$ git config --global user.name "name" # Please enter your name $ git config --global user.email "email" # Please enter your email
設定Git使用者名稱和信箱
$ git config --list
確認設定
常用操作指令
$ pwd
$ ls
List,列出當下路徑的所有資料夾和檔案
$ ls -a
List all,列出包含隱藏的所有資料夾和檔案,隱藏的檔案前會有「.」做標示
$ ls -al
List all with long listing format,顯示列表以及詳細資料
$ mkdir <directory name>
Make directory,新增資料夾
$ cd <directory name>
Change Directory,進入資料夾,回上一頁則鍵入$ cd ..
$ touch <file name>
Touch,新增檔案
$ rm <file name>
Remove,移除檔案
$ cp parameterA parameterB
Copy,複製檔案,參數A:要複製的檔案;參數B:複製後的檔名/路徑
$ mv parameterA parameterB
Move,移動檔案,或是修改檔名,參數A:目標檔案;參數B:移動的路徑,或是新檔名
$ ls | grep 'something'
grep可用來搭配篩選僅含某字串列表
$ cat <file name>
Concatenate,預覽檔案內容
版本控制指令
[~/git-demo] $ git init登錄專案,當下路徑須位於專案資料夾路徑中,登錄後專案資料夾中會新增.git的隱藏資料夾,可移除或複製此資料夾去進行移除或拷貝的動作
[~/git-demo] $ git add <file name> [~/git-demo] $ git add .
登記更動,準備提交。git add .可直接登記當前路徑所有檔案
[~/git-demo] $ git commit -m "commit message"
[~/git-demo] $ git status查看狀態,綠色檔案為已登錄,準備提交;紅色檔案為有修改程式碼,但尚未登錄
雲端儲存Github相關指令
[~/git-demo] $ git remote[~/git-demo] $ git remote -v顯示此專案的遠端儲存庫,-v可列出詳細清單,分開列出$ git fetch和$ git push的遠端儲存庫位置
[~/git-demo] $ git remote add <name> <url>新增遠端儲存庫,名字可自定義,可設定多個遠端儲存庫
[~/git-demo] $ git remote remove <name>移除遠端儲存庫
[~/git-demo] $ git push <repository name> <branch name>[~/git-demo] $ git push -u <repository name> <branch name>推送分支到遠端儲存庫。-u 是 --setup-upstream,可設定推送上游,之後直接輸入git push即可推送到已設定的上游
$ git clone <url>
複製 / 下載專案,可觀看使用他人的專案內容
沒有留言:
張貼留言