1GITCVS-MIGRATION(7) Git Manual GITCVS-MIGRATION(7)
2
3
4
6 gitcvs-migration - git for CVS users
7
9 git cvsimport *
10
12 Git differs from CVS in that every working tree contains a repository
13 with a full copy of the project history, and no repository is
14 inherently more important than any other. However, you can emulate the
15 CVS model by designating a single shared repository which people can
16 synchronize with; this document explains how to do that.
17
18 Some basic familiarity with git is required. Having gone through
19 gittutorial(7) and gitglossary(7) should be sufficient.
20
22 Suppose a shared repository is set up in /pub/repo.git on the host
23 foo.com. Then as an individual committer you can clone the shared
24 repository over ssh with:
25
26 $ git clone foo.com:/pub/repo.git/ my-project
27 $ cd my-project
28
29
30 and hack away. The equivalent of cvs update is
31
32 $ git pull origin
33
34
35 which merges in any work that others might have done since the clone
36 operation. If there are uncommitted changes in your working tree,
37 commit them first before running git pull.
38
39 Note
40 The pull command knows where to get updates from because of certain
41 configuration variables that were set by the first git clone
42 command; see git config -l and the git-config(1) man page for
43 details.
44
45 You can update the shared repository with your changes by first
46 committing your changes, and then using the git push command:
47
48 $ git push origin master
49
50
51 to "push" those commits to the shared repository. If someone else has
52 updated the repository more recently, git push, like cvs commit, will
53 complain, in which case you must pull any changes before attempting the
54 push again.
55
56 In the git push command above we specify the name of the remote branch
57 to update (master). If we leave that out, git push tries to update any
58 branches in the remote repository that have the same name as a branch
59 in the local repository. So the last push can be done with either of:
60
61 $ git push origin
62 $ git push foo.com:/pub/project.git/
63
64
65 as long as the shared repository does not have any branches other than
66 master.
67
69 We assume you have already created a git repository for your project,
70 possibly created from scratch or from a tarball (see gittutorial(7)),
71 or imported from an already existing CVS repository (see the next
72 section).
73
74 Assume your existing repo is at /home/alice/myproject. Create a new
75 "bare" repository (a repository without a working tree) and fetch your
76 project into it:
77
78 $ mkdir /pub/my-repo.git
79 $ cd /pub/my-repo.git
80 $ git --bare init --shared
81 $ git --bare fetch /home/alice/myproject master:master
82
83
84 Next, give every team member read/write access to this repository. One
85 easy way to do this is to give all the team members ssh access to the
86 machine where the repository is hosted. If you don’t want to give them
87 a full shell on the machine, there is a restricted shell which only
88 allows users to do git pushes and pulls; see git-shell(1).
89
90 Put all the committers in the same group, and make the repository
91 writable by that group:
92
93 $ chgrp -R $group /pub/my-repo.git
94
95
96 Make sure committers have a umask of at most 027, so that the
97 directories they create are writable and searchable by other group
98 members.
99
101 First, install version 2.1 or higher of cvsps from
102 http://www.cobite.com/cvsps/ and make sure it is in your path. Then cd
103 to a checked out CVS working directory of the project you are
104 interested in and run git-cvsimport(1):
105
106 $ git cvsimport -C <destination> <module>
107
108
109 This puts a git archive of the named CVS module in the directory
110 <destination>, which will be created if necessary.
111
112 The import checks out from CVS every revision of every file. Reportedly
113 cvsimport can average some twenty revisions per second, so for a
114 medium-sized project this should not take more than a couple of
115 minutes. Larger projects or remote repositories may take longer.
116
117 The main trunk is stored in the git branch named origin, and additional
118 CVS branches are stored in git branches with the same names. The most
119 recent version of the main trunk is also left checked out on the master
120 branch, so you can start adding your own changes right away.
121
122 The import is incremental, so if you call it again next month it will
123 fetch any CVS updates that have been made in the meantime. For this to
124 work, you must not modify the imported branches; instead, create new
125 branches for your own changes, and merge in the imported branches as
126 necessary.
127
128 If you want a shared repository, you will need to make a bare clone of
129 the imported directory, as described above. Then treat the imported
130 directory as another development clone for purposes of merging
131 incremental imports.
132
134 Git allows you to specify scripts called "hooks" to be run at certain
135 points. You can use these, for example, to send all commits to the
136 shared repository to a mailing list. See githooks(5).
137
138 You can enforce finer grained permissions using update hooks. See
139 Controlling access to branches using update hooks[1].
140
142 It is also possible to provide true CVS access to a git repository, so
143 that developers can still use CVS; see git-cvsserver(1) for details.
144
146 CVS users are accustomed to giving a group of developers commit access
147 to a common repository. As we’ve seen, this is also possible with git.
148 However, the distributed nature of git allows other development models,
149 and you may want to first consider whether one of them might be a
150 better fit for your project.
151
152 For example, you can choose a single person to maintain the project’s
153 primary public repository. Other developers then clone this repository
154 and each work in their own clone. When they have a series of changes
155 that they’re happy with, they ask the maintainer to pull from the
156 branch containing the changes. The maintainer reviews their changes and
157 pulls them into the primary repository, which other developers pull
158 from as necessary to stay coordinated. The Linux kernel and other
159 projects use variants of this model.
160
161 With a small group, developers may just pull changes from each other’s
162 repositories without the need for a central maintainer.
163
165 gittutorial(7), gittutorial-2(7), gitcore-tutorial(7), gitglossary(7),
166 Everyday Git[2], The Git User’s Manual[3]
167
169 Part of the git(1) suite.
170
172 1. Controlling access to branches using update hooks
173 file:///usr/share/doc/git-1.7.4.4/howto/update-hook-example.txt
174
175 2. Everyday Git
176 file:///usr/share/doc/git-1.7.4.4/everyday.html
177
178 3. The Git User’s Manual
179 file:///usr/share/doc/git-1.7.4.4/user-manual.html
180
181
182
183Git 1.7.4.4 04/11/2011 GITCVS-MIGRATION(7)