Linux下常用cvs命令整理

來源:互聯網
上載者:User

   1.登入:

  $export CVSROOT=:pserver:username@the_server_name:/home/cvsroot

  Note:pserver是訪問方式,如果伺服器設定的是口令認證,則是 pserver。

  username是 CVS伺服器的使用者名稱,可以根據你的設定修改;

  the_server_name是CVS伺服器的名稱或者IP地址;

  /home/cvsroot是你的CVS伺服器的CVSROOT目錄,根據你的CVS伺服器設定做修改或者詢問管理員.

  登陸CVS伺服器:

  $cvs login

  這時候cvs會問你口令,請把你在CVS伺服器上的口令敲進去:

  Passwd:xxxxxxxx

  2. 提交項目--import

  cvs import [-options] repository vendortag releasetag...

  Note: 該命令將目前的目錄下的所有檔案(包括子目錄)匯入原始碼儲存庫。

  repository :項目名稱,在CVS伺服器上會建立以這個名字命名的倉庫。

  vendortag : 項目分支的總標記。(不常用)

  releasetag :標識檔案的輸入層次的標記。 (一般用start)

  使用import提交項目的時候,CVS會要求對項目進行說明。在預設狀態下,CVS會彈出文字編輯器。使用者也可以用-m “log_message”來輸入說明資訊。

  例如

  $cvs import -m "upload the first time as new module" judecvs v_0_0_1 start

  提示:import 一般在第一次匯入module時使用。後期修改檔案後可直接使用commit命令提交修改的檔案。

  3. 從CVS匯出項目--checkout

  cvs checkout [options] modules...

  此命令將原始碼儲存庫中已有的項目匯出到目前的目錄。

  modules :項目名稱

  例如,從倉庫中檢索出judecvs項目的源檔案.

  $cvs checkout judecvs

  4.CVS 主要命令---update 更新當前工作目錄中的檔案

  cvs update [-options] [files...]

  此命令比較指定CVS源碼庫中的檔案和目前的目錄下的檔案,如果CVS源碼庫中有更高版本的源檔案,則更新目前的目錄下的檔案。此命令只有在checkout命令使用過後才能使用。

  在執行update命令時,CVS並不是簡單的將新版本覆蓋當前檔案,而是試圖將新版本所做的修改添加到當前檔案中去。如果發生衝突,CVS會以字串 “<<<<<<”和“>>>>>>”來表示衝突發生。這時候你可以修改檔案,重新提交。

  提示:如果你已經做過一次checkout了,那麼不需要重新checkout,只需要進入cvstest項目的目錄,更新一把就行了:

  例如:

  $cd judecvs

  $cvs update

  5.CVS 主要命令---status 如果你不想直接更新,只是想看看有沒有更新的東西,那麼:

  $cvs status

  會給每個檔案有一份狀態報表,類似這樣:

  ==================================================

  File: client.c Status: Up-to-date

  Working revision: 1.1.1.1 'Some Date'

  Repository revision: 1.2 /home2/cvsroot/judecvs/client.c,v

  這裡最重要的就是 Status 欄,這裡總共可能有四種狀態:

  Up-to-date:表明你要到的檔案是最新的.

  Locally Modified:表明你曾經修改過該檔案,但還沒有提交,你的版本比倉庫裡的新.

  Needing Patch:表明有人已經修改過該檔案並且已經提交了!你的版本比倉庫裡的舊.

  Needs Merge:表明你曾經修改國該檔案,但是別人也修改了這個檔案,而且還提交給倉庫了!

  6.CVS 主要命令---commit 儲存修改到CVS中

  cvs commit [-lnR] [-m 'log_message' | -f file] [-r revision] [files...]

  此命令將目前的目錄下的原始碼與CVS中最新版本比較,並進行更新。

  [-m ‘log_message‘ ] :輸入修改說明。

  [-r revision] :指定版本。

  [files...] :指定修改檔案。

  $cvs commit -m "add XXX function" client.c

  系統會提示

  CVS: ----------------------------------------------------------------------

  CVS: Enter Log. Lines beginning with `CVS:' are removed automatically

  CVS:

  CVS: Committing in .

  CVS:

  CVS: Modified Files:

  CVS: client.c

  CVS: ----------------------------------------------------------------------

  退出後,系統詢問是否continue,輸入c,則完成checkin

  Log message unchanged or not specified

  a)bort, c)ontinue, e)dit, !)reuse this message unchanged for remaining dirs

  Action: (continue) c

  Checking in client.c;

  /home2/cvsroot/judecvs/client.c,v <-- client.c

  new revision: 1.2; previous revision: 1.1

  done

  如果CVS上檔案已經有其他人更新,也就是我當前工作的不是最新版本,系統提示commit失敗,這時候需要先update,然後把整合檔案再commit.

  cvs server: Up-to-date check failed for `client.c'

  cvs [server aborted]: correct above errors first!

  cvs commit: saving log message in /tmp/cvsCEjA9N

  提示:修改檔案之前先update或者先查看檔案狀態,確認當前工作版本是最新版本。

  7.添加檔案到項目中---add

  cvs add [-k kflag] [-m 'message'] files...

  此命令並不真正添加檔案,只是將檔案註冊到項目中,要真正添加檔案,還要使用commit命令。

  例如:

  $cvs add -m "test add" testadd.c

  提示:

  cvs server: scheduling file `testadd.c' for addition on branch `v_0_0_2'

  cvs server: use 'cvs commit' to add this file permanently

  $cvs commit

  同commit過程一樣,CVS將testadd.c添加到項目中

  8.CVS 主要命令---remove 從項目中刪除檔案

  cvs remove [-k kflag] [-m 'message'] files...

  和add命令一樣,此命令並不真正刪除檔案,只是將檔案從項目中取消,要真正刪除檔案,還要使用commit命令。

  e.g.

  $rm testadd.c

  $cvs rm testadd.c

  系統提示

  cvs server: scheduling `testadd.c' for removal

  cvs server: use 'cvs commit' to remove this file permanently

  $cvs commit testadd.c

  此時,CVS才將testadd.c從項目的最新版本中刪除,但是如果它有以前的版本,以前版本依然存在。

  一些常用命令的簡化形式:

  cvs co

  cvs up filename 提交修改

  cvs ci filename 確認修改

  cvs log filename 察看修改日誌

  cvs st filename 察看檔案狀態

  cvs rm filename 將某個源檔案物理刪除

  在linux上使用cvs命令

  1)登陸CVS伺服器:

  cvs -d :pserver:username@host:/$CVSROOT login

  然後系統會提示你輸入密碼。或直接使用:

  cvs -d :pserver:user:pwd@host:/CVS login

  2) checkout:

  cvs -d :pserver:host:/CVSROOT checkout projectName

  3) 如果想省略上面的-d以及服務類別目錄,執行:

  export CVSROOT=:pserver:user@host:/cvsroot

  4) update:

  cvs update

  cvs update -C (override and update)

  5) cvs status: 顯示當前檔案的更新狀態.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.