Git指令
前言
Git是目前軟體工程師幾乎必備的技能,礙於每次使用都忘記指令跟概念,這裡記錄目前所學的Git概念與指令!
Git是一個分佈式的版本控制系統,
指令
- 查詢git設定欓
git config --list - 初始化
git init - 檢查狀態
git status - 追蹤檔案
git add file_name - 刪除追蹤檔案(返回更改前狀態)
git checkout -- file_name - 提交檔案至待存區
git commit -m "提交說明" - 修改上一次提交備註
git commit --amend - 查詢過往提交(commit)紀錄
git log
- 將待存區上傳至雲端
git push ssh://example.com/~/www/project.git - 下載檔案
git clone ssh://example.com/~/www/project.git - 下載更新
git pull - 查看分歧狀態
git branch - 查看遠端分歧
git branch -rorgit branch --remote - 創建分歧(branch)
git branch branch_name - 切換分歧
git checkout branch_name - 合併分歧(merge)
- 在分歧中提交紀錄(commit)
- 切回主要分歧
git checkout master - 合併分歧
git merge branch_name