blob: aaa7ef737a4c190c60e37e2849ce42f3bdb5dda7 [file] [log] [blame]
Junio C Hamanodfccbb02008-05-26 01:16:141gitcvs-migration(7)
2===================
3
4NAME
5----
6gitcvs-migration - git for CVS users
7
8SYNOPSIS
9--------
10git cvsimport *
11
12DESCRIPTION
13-----------
Junio C Hamano1a4e8412005-12-27 08:17:2314
Junio C Hamano5102d9a2006-12-08 07:23:4615Git differs from CVS in that every working tree contains a repository with
16a full copy of the project history, and no repository is inherently more
17important than any other. However, you can emulate the CVS model by
18designating a single shared repository which people can synchronize with;
19this document explains how to do that.
Junio C Hamano1a4e8412005-12-27 08:17:2320
Junio C Hamanofce7c7e2008-07-02 03:06:3821Some basic familiarity with git is required. Having gone through
22linkgit:gittutorial[7] and
23linkgit:gitglossary[7] should be sufficient.
Junio C Hamano1a4e8412005-12-27 08:17:2324
Junio C Hamano5102d9a2006-12-08 07:23:4625Developing against a shared repository
26--------------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:2327
Junio C Hamano5102d9a2006-12-08 07:23:4628Suppose a shared repository is set up in /pub/repo.git on the host
29foo.com. Then as an individual committer you can clone the shared
30repository over ssh with:
Junio C Hamano1a4e8412005-12-27 08:17:2331
Junio C Hamano5102d9a2006-12-08 07:23:4632------------------------------------------------
33$ git clone foo.com:/pub/repo.git/ my-project
34$ cd my-project
35------------------------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:2336
Junio C Hamanoba4b9282008-07-06 05:20:3137and hack away. The equivalent of 'cvs update' is
Junio C Hamano1a4e8412005-12-27 08:17:2338
Junio C Hamano5102d9a2006-12-08 07:23:4639------------------------------------------------
40$ git pull origin
41------------------------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:2342
Junio C Hamano5102d9a2006-12-08 07:23:4643which merges in any work that others might have done since the clone
44operation. If there are uncommitted changes in your working tree, commit
45them first before running git pull.
46
47[NOTE]
48================================
Junio C Hamanoba4b9282008-07-06 05:20:3149The 'pull' command knows where to get updates from because of certain
50configuration variables that were set by the first 'git-clone'
Junio C Hamano35738e82008-01-07 07:55:4651command; see `git config -l` and the linkgit:git-config[1] man
Junio C Hamanod3361ad2007-01-01 03:20:2452page for details.
Junio C Hamano5102d9a2006-12-08 07:23:4653================================
54
Junio C Hamano96010b22006-12-09 21:15:4655You can update the shared repository with your changes by first committing
Junio C Hamanoba4b9282008-07-06 05:20:3156your changes, and then using the 'git-push' command:
Junio C Hamano5102d9a2006-12-08 07:23:4657
58------------------------------------------------
59$ git push origin master
60------------------------------------------------
61
62to "push" those commits to the shared repository. If someone else has
Junio C Hamanoba4b9282008-07-06 05:20:3163updated the repository more recently, 'git-push', like 'cvs commit', will
Junio C Hamano5102d9a2006-12-08 07:23:4664complain, in which case you must pull any changes before attempting the
65push again.
66
Junio C Hamanoba4b9282008-07-06 05:20:3167In the 'git-push' command above we specify the name of the remote branch
68to update (`master`). If we leave that out, 'git-push' tries to update
Junio C Hamano5102d9a2006-12-08 07:23:4669any branches in the remote repository that have the same name as a branch
Junio C Hamanoba4b9282008-07-06 05:20:3170in the local repository. So the last 'push' can be done with either of:
Junio C Hamano5102d9a2006-12-08 07:23:4671
72------------
73$ git push origin
74$ git push foo.com:/pub/project.git/
75------------
76
77as long as the shared repository does not have any branches
78other than `master`.
79
80Setting Up a Shared Repository
81------------------------------
82
83We assume you have already created a git repository for your project,
Junio C Hamanofce7c7e2008-07-02 03:06:3884possibly created from scratch or from a tarball (see
85linkgit:gittutorial[7]), or imported from an already existing CVS
Junio C Hamano5102d9a2006-12-08 07:23:4686repository (see the next section).
87
Junio C Hamano96010b22006-12-09 21:15:4688Assume your existing repo is at /home/alice/myproject. Create a new "bare"
89repository (a repository without a working tree) and fetch your project into
90it:
Junio C Hamano5102d9a2006-12-08 07:23:4691
92------------------------------------------------
Junio C Hamano96010b22006-12-09 21:15:4693$ mkdir /pub/my-repo.git
94$ cd /pub/my-repo.git
Junio C Hamano24351a82007-01-13 08:09:1795$ git --bare init --shared
Junio C Hamano96010b22006-12-09 21:15:4696$ git --bare fetch /home/alice/myproject master:master
Junio C Hamano5102d9a2006-12-08 07:23:4697------------------------------------------------
98
99Next, give every team member read/write access to this repository. One
100easy way to do this is to give all the team members ssh access to the
101machine where the repository is hosted. If you don't want to give them a
102full shell on the machine, there is a restricted shell which only allows
Junio C Hamano35738e82008-01-07 07:55:46103users to do git pushes and pulls; see linkgit:git-shell[1].
Junio C Hamano5102d9a2006-12-08 07:23:46104
105Put all the committers in the same group, and make the repository
106writable by that group:
107
108------------------------------------------------
Junio C Hamano96010b22006-12-09 21:15:46109$ chgrp -R $group /pub/my-repo.git
Junio C Hamano5102d9a2006-12-08 07:23:46110------------------------------------------------
111
112Make sure committers have a umask of at most 027, so that the directories
113they create are writable and searchable by other group members.
Junio C Hamano353c3a92006-12-06 21:11:49114
Junio C Hamano1a4e8412005-12-27 08:17:23115Importing a CVS archive
116-----------------------
117
Junio C Hamanocfa7ad02006-01-31 07:10:49118First, install version 2.1 or higher of cvsps from
119link:http://www.cobite.com/cvsps/[http://www.cobite.com/cvsps/] and make
Junio C Hamano96010b22006-12-09 21:15:46120sure it is in your path. Then cd to a checked out CVS working directory
Junio C Hamanoba4b9282008-07-06 05:20:31121of the project you are interested in and run 'git-cvsimport':
Junio C Hamano1a4e8412005-12-27 08:17:23122
Junio C Hamanocfa7ad02006-01-31 07:10:49123-------------------------------------------
Junio C Hamanoaa83a7d2007-03-05 02:37:29124$ git cvsimport -C <destination> <module>
Junio C Hamanocfa7ad02006-01-31 07:10:49125-------------------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:23126
Junio C Hamanocfa7ad02006-01-31 07:10:49127This puts a git archive of the named CVS module in the directory
Junio C Hamano96010b22006-12-09 21:15:46128<destination>, which will be created if necessary.
Junio C Hamano1a4e8412005-12-27 08:17:23129
Junio C Hamanocfa7ad02006-01-31 07:10:49130The import checks out from CVS every revision of every file. Reportedly
131cvsimport can average some twenty revisions per second, so for a
132medium-sized project this should not take more than a couple of minutes.
133Larger projects or remote repositories may take longer.
Junio C Hamano1a4e8412005-12-27 08:17:23134
Junio C Hamanocfa7ad02006-01-31 07:10:49135The main trunk is stored in the git branch named `origin`, and additional
136CVS branches are stored in git branches with the same names. The most
137recent version of the main trunk is also left checked out on the `master`
138branch, so you can start adding your own changes right away.
Junio C Hamano1a4e8412005-12-27 08:17:23139
Junio C Hamanocfa7ad02006-01-31 07:10:49140The import is incremental, so if you call it again next month it will
141fetch any CVS updates that have been made in the meantime. For this to
142work, you must not modify the imported branches; instead, create new
143branches for your own changes, and merge in the imported branches as
144necessary.
Junio C Hamano1a4e8412005-12-27 08:17:23145
Junio C Hamanoba4b9282008-07-06 05:20:31146If you want a shared repository, you will need to make a bare clone
147of the imported directory, as described above. Then treat the imported
148directory as another development clone for purposes of merging
149incremental imports.
150
Junio C Hamano5102d9a2006-12-08 07:23:46151Advanced Shared Repository Management
152-------------------------------------
153
154Git allows you to specify scripts called "hooks" to be run at certain
155points. You can use these, for example, to send all commits to the shared
Junio C Hamanofce7c7e2008-07-02 03:06:38156repository to a mailing list. See linkgit:githooks[5].
Junio C Hamano5102d9a2006-12-08 07:23:46157
158You can enforce finer grained permissions using update hooks. See
159link:howto/update-hook-example.txt[Controlling access to branches using
160update hooks].
161
162Providing CVS Access to a git Repository
163----------------------------------------
164
165It is also possible to provide true CVS access to a git repository, so
Junio C Hamano35738e82008-01-07 07:55:46166that developers can still use CVS; see linkgit:git-cvsserver[1] for
Junio C Hamano5102d9a2006-12-08 07:23:46167details.
168
169Alternative Development Models
170------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:23171
Junio C Hamanocfa7ad02006-01-31 07:10:49172CVS users are accustomed to giving a group of developers commit access to
Junio C Hamano5102d9a2006-12-08 07:23:46173a common repository. As we've seen, this is also possible with git.
174However, the distributed nature of git allows other development models,
175and you may want to first consider whether one of them might be a better
176fit for your project.
Junio C Hamano1a4e8412005-12-27 08:17:23177
Junio C Hamanocfa7ad02006-01-31 07:10:49178For example, you can choose a single person to maintain the project's
179primary public repository. Other developers then clone this repository
180and each work in their own clone. When they have a series of changes that
181they're happy with, they ask the maintainer to pull from the branch
182containing the changes. The maintainer reviews their changes and pulls
183them into the primary repository, which other developers pull from as
184necessary to stay coordinated. The Linux kernel and other projects use
185variants of this model.
Junio C Hamano1a4e8412005-12-27 08:17:23186
Junio C Hamanocfa7ad02006-01-31 07:10:49187With a small group, developers may just pull changes from each other's
188repositories without the need for a central maintainer.
Junio C Hamanodfccbb02008-05-26 01:16:14189
190SEE ALSO
191--------
Junio C Hamano9e1793f2008-06-02 07:31:16192linkgit:gittutorial[7],
193linkgit:gittutorial-2[7],
194linkgit:gitcore-tutorial[7],
195linkgit:gitglossary[7],
Junio C Hamanodfccbb02008-05-26 01:16:14196link:everyday.html[Everyday Git],
197link:user-manual.html[The Git User's Manual]
198
199GIT
200---
Junio C Hamanof7c042d2008-06-06 22:50:53201Part of the linkgit:git[1] suite.