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