GIT 基本指令


Posted by fang on 2020-06-19

常見指令

  • git init: 初始化,準備對該檔案進行版控
  • git status: 查看版控狀況
  • git add + 檔案名稱: 將該檔案加入版控
  • git add .:將所有檔案加入版控
  • git rm --cashed + 檔案名稱: 取消該檔案的版控
  • git commit: 新建一個版控,在vim進行文字編輯
  • git commit -m: 新建一個版控,直接輸入文字
  • git log: 查看歷史資料
  • git log —oneline: 查看歷史資料,簡短地顯示
  • git checkout + 版本commit: 回到該版本的檔案
  • git checkout master: 回到 master 分支
  • git diff: 看這次與上次之間改了什麼

加入版本控制不代表commit了

  1. 加入版本控制-git add(把東西放入資料夾暫存)
  2. 新建版本-git commit(把資料夾命名)

其他常見功能

  • .gitignor: 在vim .gitignor 裡面輸入不想被追蹤的檔案名稱(.gitignor本身也要加入版控)
  • git commit -am: 同時進行 git add. 和 git commit -m(但是僅限現有的檔案,新增的檔案不會被add)
  • git commit --amend: commit 訊息輸入錯誤,用此指令修改
  • git reset HEAD^: commit 之後又想刪除commit;分為三種模式

  • 三種模式參考:Git reset 的三種模式

  • git checkout -- + 檔案名稱: 檔案回到還沒修改之前的樣子


#Git #版本控制







Related Posts

耦合 (coupling)

耦合 (coupling)

Day 121

Day 121

MTR04_1026

MTR04_1026


Comments