目录 搜索
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
文字

命名

gitcvs-migration - Git for CVS users

概要

git cvsimport *

描述

Git 与 CVS 的不同之处在于,每个工作树都包含一个具有项目历史记录完整副本的存储库,并且任何存储库本身都比其他任何存储库都重要。但是,您可以通过指定人员可以同步的单个共享存储库来模拟 CVS 模型; 本文档解释了如何做到这一点。

对 Git 有一些基本的了解是必需的。通过 gittutorial [7] 和 gitglossary [7] 就足够了。

针对共享存储库进行开发

假设在主机 foo.com 上的 /pub/repo.git 中设置了共享存储库。然后作为一个单独的提交者,你可以通过 ssh 克隆共享库:

$ git clone foo.com:/pub/repo.git/ my-project
$ cd my-project

并删去。相当于cvs update

$ git pull origin

它合并在副本操作后其他人可能完成的任何工作中。如果工作树中有未提交的更改,请在运行 git pull 之前先提交它们。

Note

The pull command knows where to get updates from because of certain configuration variables that were set by the first git clone command; see git config -l and the git-config1 man page for details.

您可以通过首先提交更改并使用以下git push命令来更新共享存储库:

$ git push origin master

将这些提交 “push” 到共享存储库。如果其他人最近更新了存储库git push,就像cvs commit会抱怨的那样,在这种情况下,您必须在尝试再次推送前进行任何更改。

git push上面的命令中,我们指定了要更新(master)的远程分支的名称。如果我们不这样做,则git push尝试更新远程存储库中与本地存储库中的分支具有相同名称的任何分支。所以最后push可以通过以下任一方式完成:

$ git push origin
$ git push foo.com:/pub/project.git/

只要共享存储库没有任何其他分支master

设置共享存储库

我们假设您已经为您的项目创建了一个 Git 存储库,可能是从头开始或从 tarball 创建的(请参阅 gittutorial [7]),或者从现有的 CVS 存储库导入(请参阅下一节)。

假设您的现有回购在 / home / alice / myproject 。创建一个新的 “bare” 存储库(一个没有工作树的存储库)并将你的项目存入它:

$ mkdir /pub/my-repo.git
$ cd /pub/my-repo.git
$ git --bare init --shared
$ git --bare fetch /home/alice/myproject master:master

接下来,让每个团队成员都可以读取/写入这个存储库。一个简单的方法是让所有团队成员 ssh 访问存储库所在的机器。如果你不想在机器上给它们一个完整的外壳,那么就有一个限制外壳,它只允许用户做 Git 推动和拉动; 请参阅 git-shell [1] 。

将所有提交者放在同一组中,并使该存储库可由该组写入:

$ chgrp -R $group /pub/my-repo.git

确保提交者拥有最多027的 umask ,以便他们创建的目录可由其他组成员写入和搜索。

导入一个 cvs 档案

Note

These instructions use the git-cvsimport script which ships with git, but other importers may provide better results. See the note in git-cvsimport1 for other options.

首先,从https://github.com/andreyvit/cvsps安装 cvsps2.1 或更高版本,并确保它在你的路径中。然后 cd 到您感兴趣的项目的签出 CVS 工作目录并运行 git-cvsimport [1] :

$ git cvsimport -C <destination> <module>

这会将名为 CVS 模块的 Git 存档放在目录 <destination> 中,如果需要将会创建它。

导入从 CVS 检出每个文件的每个修订版本。据报道,cvsimport 平均每秒可以修改大约20个版本,所以对于一个中等规模的项目来说,这应该不会超过几分钟。较大的项目或远程存储库可能需要更长的时间。

主干存储在命名为origin的 Git 分支中,其他 CVS 分支存储在具有相同名称的 Git 分支中。主干线的最新版本也会在master分支上检出,因此您可以立即开始添加自己的更改。

导入是增量式的,所以如果你在下个月再次调用它,它将获取在此期间所做的任何 CVS 更新。为此,您不得修改导入的分支; 相反,请为自己的更改创建新分支,并根据需要合并输入分支。

如果您需要共享存储库,则需要对导入的目录进行裸机复制,如上所述。然后将导入的目录作为另一个开发副本用于合并增量导入。

高级共享存储库管理

Git 允许你指定在某些点运行的叫做 “hooks” 的脚本。例如,您可以使用它们将所有提交到共享存储库的邮件发送到邮件列表。见 githooks [5] 。

您可以使用更新挂钩来实施更细粒度的权限。请参阅使用更新挂钩控制对分支机构的访问。

提供对 git 存储库的 cvs 访问

还可以提供对 Git 存储库的真正 CVS 访问,以便开发人员仍然可以使用 CVS ; 有关详细信息,请参阅 git-cvsserver [1] 。

替代发展模式

CVS 用户习惯于让一组开发人员访问公共存储库。正如我们所看到的,Git 也可以这样做。但是,Git 的分布式特性允许其他开发模型,您可能需要首先考虑其中一个模型是否适合您的项目。

例如,您可以选择一个人来维护项目的主要公共存储库。其他开发人员然后复制这个存储库,并在他们自己的副本中工作 当他们有一系列他们感到满意的变化时,他们会要求维护人员从包含变更的分支中撤出。维护人员检查他们的变化并将他们拖入主存储库中,其他开发人员根据需要从中取得协调。Linux 内核和其他项目使用此模型的变体。

通过一个小团队,开发人员可以在不需要集中维护人员的情况下从对方的存储库中获取更改。

上一篇: 下一篇: