雖然 Git 已成主流,但部分老舊專案仍使用 CVS。本文整理 CVS 核心工作流指令,涵蓋登入、匯入、檢出、更新、提交、新增、刪除與狀態檢視。
# 設定 CVSROOT(pserver 協議)
export CVSROOT=:pserver:username@cvs_server:/home/cvsroot
# 登入(輸入密碼)
cvs login
# 在專案根目錄執行
cvs import -m "Initial import" project_name vendor_tag release_tag
# 範例
cvs import -m "first release" myproj mycorp v1_0
vendor_tag、release_tag 為標籤慣例,通常分別用廠商名與版本號。
cvs checkout project_name
# 簡寫
cvs co project_name
| 操作 | 指令 | 說明 |
|---|---|---|
| 更新至最新版 | cvs update | 自動合併,衝突標記 <<<<<< / >>>>>> |
| 強制覆蓋更新 | cvs update -C | 放棄本地修改,強制同步倉庫版本 |
| 檢視檔案狀態 | cvs status | 四種狀態:Up-to-date / Locally Modified / Needs Patch / Needs Merge |
| 提交修改 | cvs commit -m "log msg" [files] | 需先 update 確保基於最新版 |
| 新增檔案 | cvs add file → cvs commit | add 僅登記,commit 才真正入庫 |
| 刪除檔案 | rm file → cvs remove file → cvs commit | 歷史版本保留,僅最新版移除 |
| 查看修改日誌 | cvs log file | |
| 查看差異 | cvs diff file |
cvs co = checkout
cvs up = update
cvs ci = commit
cvs st = status
cvs log = log
cvs rm = remove
cvs -d :pserver:user@host:/cvsroot checkout project
cvs -d :pserver:user:pass@host:/cvsroot login
cvs update 發現衝突(輸出 C file.c)<<<<<< 標記,手工合併cvs commit -m "resolve conflict" file.c