blob: 1cd1283d0f817d06e42ed41c31e7c02f69c1f821 [file] [log] [blame]
Junio C Hamanodfccbb02008-05-26 01:16:141gitcvs-migration(7)
2===================
3
4NAME
5----
Junio C Hamano076ffcc2013-02-06 05:13:216gitcvs-migration - Git for CVS users
Junio C Hamanodfccbb02008-05-26 01:16:147
8SYNOPSIS
9--------
Junio C Hamano15567bc2011-07-23 00:51:5910[verse]
11'git cvsimport' *
Junio C Hamanodfccbb02008-05-26 01:16:1412
13DESCRIPTION
14-----------
Junio C Hamano1a4e8412005-12-27 08:17:2315
Junio C Hamano5102d9a2006-12-08 07:23:4616Git differs from CVS in that every working tree contains a repository with
17a full copy of the project history, and no repository is inherently more
18important than any other. However, you can emulate the CVS model by
19designating a single shared repository which people can synchronize with;
20this document explains how to do that.
Junio C Hamano1a4e8412005-12-27 08:17:2321
Junio C Hamano076ffcc2013-02-06 05:13:2122Some basic familiarity with Git is required. Having gone through
Junio C Hamanofce7c7e2008-07-02 03:06:3823linkgit:gittutorial[7] and
24linkgit:gitglossary[7] should be sufficient.
Junio C Hamano1a4e8412005-12-27 08:17:2325
Junio C Hamano5102d9a2006-12-08 07:23:4626Developing against a shared repository
27--------------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:2328
Junio C Hamano5102d9a2006-12-08 07:23:4629Suppose a shared repository is set up in /pub/repo.git on the host
30foo.com. Then as an individual committer you can clone the shared
31repository over ssh with:
Junio C Hamano1a4e8412005-12-27 08:17:2332
Junio C Hamano5102d9a2006-12-08 07:23:4633------------------------------------------------
34$ git clone foo.com:/pub/repo.git/ my-project
35$ cd my-project
36------------------------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:2337
Junio C Hamanoba4b9282008-07-06 05:20:3138and hack away. The equivalent of 'cvs update' is
Junio C Hamano1a4e8412005-12-27 08:17:2339
Junio C Hamano5102d9a2006-12-08 07:23:4640------------------------------------------------
41$ git pull origin
42------------------------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:2343
Junio C Hamano5102d9a2006-12-08 07:23:4644which merges in any work that others might have done since the clone
45operation. If there are uncommitted changes in your working tree, commit
46them first before running git pull.
47
48[NOTE]
49================================
Junio C Hamanoba4b9282008-07-06 05:20:3150The 'pull' command knows where to get updates from because of certain
Junio C Hamano1aa40d22010-01-21 17:46:4351configuration variables that were set by the first 'git clone'
Junio C Hamano35738e82008-01-07 07:55:4652command; see `git config -l` and the linkgit:git-config[1] man
Junio C Hamanod3361ad2007-01-01 03:20:2453page for details.
Junio C Hamano5102d9a2006-12-08 07:23:4654================================
55
Junio C Hamano96010b22006-12-09 21:15:4656You can update the shared repository with your changes by first committing
Junio C Hamano1aa40d22010-01-21 17:46:4357your changes, and then using the 'git push' command:
Junio C Hamano5102d9a2006-12-08 07:23:4658
59------------------------------------------------
60$ git push origin master
61------------------------------------------------
62
63to "push" those commits to the shared repository. If someone else has
Junio C Hamano1aa40d22010-01-21 17:46:4364updated the repository more recently, 'git push', like 'cvs commit', will
Junio C Hamano5102d9a2006-12-08 07:23:4665complain, in which case you must pull any changes before attempting the
66push again.
67
Junio C Hamano1aa40d22010-01-21 17:46:4368In the 'git push' command above we specify the name of the remote branch
69to update (`master`). If we leave that out, 'git push' tries to update
Junio C Hamano5102d9a2006-12-08 07:23:4670any branches in the remote repository that have the same name as a branch
Junio C Hamanoba4b9282008-07-06 05:20:3171in the local repository. So the last 'push' can be done with either of:
Junio C Hamano5102d9a2006-12-08 07:23:4672
73------------
74$ git push origin
75$ git push foo.com:/pub/project.git/
76------------
77
78as long as the shared repository does not have any branches
79other than `master`.
80
81Setting Up a Shared Repository
82------------------------------
83
Junio C Hamano076ffcc2013-02-06 05:13:2184We assume you have already created a Git repository for your project,
Junio C Hamanofce7c7e2008-07-02 03:06:3885possibly created from scratch or from a tarball (see
86linkgit:gittutorial[7]), or imported from an already existing CVS
Junio C Hamano5102d9a2006-12-08 07:23:4687repository (see the next section).
88
Junio C Hamano96010b22006-12-09 21:15:4689Assume your existing repo is at /home/alice/myproject. Create a new "bare"
90repository (a repository without a working tree) and fetch your project into
91it:
Junio C Hamano5102d9a2006-12-08 07:23:4692
93------------------------------------------------
Junio C Hamano96010b22006-12-09 21:15:4694$ mkdir /pub/my-repo.git
95$ cd /pub/my-repo.git
Junio C Hamano24351a82007-01-13 08:09:1796$ git --bare init --shared
Junio C Hamano96010b22006-12-09 21:15:4697$ git --bare fetch /home/alice/myproject master:master
Junio C Hamano5102d9a2006-12-08 07:23:4698------------------------------------------------
99
100Next, give every team member read/write access to this repository. One
101easy way to do this is to give all the team members ssh access to the
102machine where the repository is hosted. If you don't want to give them a
103full shell on the machine, there is a restricted shell which only allows
Junio C Hamano076ffcc2013-02-06 05:13:21104users to do Git pushes and pulls; see linkgit:git-shell[1].
Junio C Hamano5102d9a2006-12-08 07:23:46105
106Put all the committers in the same group, and make the repository
107writable by that group:
108
109------------------------------------------------
Junio C Hamano96010b22006-12-09 21:15:46110$ chgrp -R $group /pub/my-repo.git
Junio C Hamano5102d9a2006-12-08 07:23:46111------------------------------------------------
112
113Make sure committers have a umask of at most 027, so that the directories
114they create are writable and searchable by other group members.
Junio C Hamano353c3a92006-12-06 21:11:49115
Junio C Hamano1a4e8412005-12-27 08:17:23116Importing a CVS archive
117-----------------------
118
Junio C Hamanoad70bf02016-09-26 23:44:27119NOTE: These instructions use the `git-cvsimport` script which ships with
120git, but other importers may provide better results. See the note in
121linkgit:git-cvsimport[1] for other options.
122
Junio C Hamanocfa7ad02006-01-31 07:10:49123First, install version 2.1 or higher of cvsps from
Junio C Hamanoad70bf02016-09-26 23:44:27124https://github.com/andreyvit/cvsps[https://github.com/andreyvit/cvsps] and make
Junio C Hamano96010b22006-12-09 21:15:46125sure it is in your path. Then cd to a checked out CVS working directory
Junio C Hamanoea868332009-04-21 08:11:06126of the project you are interested in and run linkgit:git-cvsimport[1]:
Junio C Hamano1a4e8412005-12-27 08:17:23127
Junio C Hamanocfa7ad02006-01-31 07:10:49128-------------------------------------------
Junio C Hamanoaa83a7d2007-03-05 02:37:29129$ git cvsimport -C <destination> <module>
Junio C Hamanocfa7ad02006-01-31 07:10:49130-------------------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:23131
Junio C Hamano076ffcc2013-02-06 05:13:21132This puts a Git archive of the named CVS module in the directory
Junio C Hamano96010b22006-12-09 21:15:46133<destination>, which will be created if necessary.
Junio C Hamano1a4e8412005-12-27 08:17:23134
Junio C Hamanocfa7ad02006-01-31 07:10:49135The import checks out from CVS every revision of every file. Reportedly
136cvsimport can average some twenty revisions per second, so for a
137medium-sized project this should not take more than a couple of minutes.
138Larger projects or remote repositories may take longer.
Junio C Hamano1a4e8412005-12-27 08:17:23139
Junio C Hamano076ffcc2013-02-06 05:13:21140The main trunk is stored in the Git branch named `origin`, and additional
141CVS branches are stored in Git branches with the same names. The most
Junio C Hamanocfa7ad02006-01-31 07:10:49142recent version of the main trunk is also left checked out on the `master`
143branch, so you can start adding your own changes right away.
Junio C Hamano1a4e8412005-12-27 08:17:23144
Junio C Hamanocfa7ad02006-01-31 07:10:49145The import is incremental, so if you call it again next month it will
146fetch any CVS updates that have been made in the meantime. For this to
147work, you must not modify the imported branches; instead, create new
148branches for your own changes, and merge in the imported branches as
149necessary.
Junio C Hamano1a4e8412005-12-27 08:17:23150
Junio C Hamanoba4b9282008-07-06 05:20:31151If you want a shared repository, you will need to make a bare clone
152of the imported directory, as described above. Then treat the imported
153directory as another development clone for purposes of merging
154incremental imports.
155
Junio C Hamano5102d9a2006-12-08 07:23:46156Advanced Shared Repository Management
157-------------------------------------
158
159Git allows you to specify scripts called "hooks" to be run at certain
160points. You can use these, for example, to send all commits to the shared
Junio C Hamanofce7c7e2008-07-02 03:06:38161repository to a mailing list. See linkgit:githooks[5].
Junio C Hamano5102d9a2006-12-08 07:23:46162
163You can enforce finer grained permissions using update hooks. See
Junio C Hamanoe6f28d02013-09-17 21:34:00164link:howto/update-hook-example.html[Controlling access to branches using
Junio C Hamano5102d9a2006-12-08 07:23:46165update hooks].
166
Junio C Hamano076ffcc2013-02-06 05:13:21167Providing CVS Access to a Git Repository
Junio C Hamano5102d9a2006-12-08 07:23:46168----------------------------------------
169
Junio C Hamano076ffcc2013-02-06 05:13:21170It is also possible to provide true CVS access to a Git repository, so
Junio C Hamano35738e82008-01-07 07:55:46171that developers can still use CVS; see linkgit:git-cvsserver[1] for
Junio C Hamano5102d9a2006-12-08 07:23:46172details.
173
174Alternative Development Models
175------------------------------
Junio C Hamano1a4e8412005-12-27 08:17:23176
Junio C Hamanocfa7ad02006-01-31 07:10:49177CVS users are accustomed to giving a group of developers commit access to
Junio C Hamano076ffcc2013-02-06 05:13:21178a common repository. As we've seen, this is also possible with Git.
179However, the distributed nature of Git allows other development models,
Junio C Hamano5102d9a2006-12-08 07:23:46180and you may want to first consider whether one of them might be a better
181fit for your project.
Junio C Hamano1a4e8412005-12-27 08:17:23182
Junio C Hamanocfa7ad02006-01-31 07:10:49183For example, you can choose a single person to maintain the project's
184primary public repository. Other developers then clone this repository
185and each work in their own clone. When they have a series of changes that
186they're happy with, they ask the maintainer to pull from the branch
187containing the changes. The maintainer reviews their changes and pulls
188them into the primary repository, which other developers pull from as
189necessary to stay coordinated. The Linux kernel and other projects use
190variants of this model.
Junio C Hamano1a4e8412005-12-27 08:17:23191
Junio C Hamanocfa7ad02006-01-31 07:10:49192With a small group, developers may just pull changes from each other's
193repositories without the need for a central maintainer.
Junio C Hamanodfccbb02008-05-26 01:16:14194
195SEE ALSO
196--------
Junio C Hamano9e1793f2008-06-02 07:31:16197linkgit:gittutorial[7],
198linkgit:gittutorial-2[7],
199linkgit:gitcore-tutorial[7],
200linkgit:gitglossary[7],
Junio C Hamano446e30b2014-10-16 21:30:32201linkgit:giteveryday[7],
Junio C Hamanodfccbb02008-05-26 01:16:14202link:user-manual.html[The Git User's Manual]
203
204GIT
205---
Junio C Hamanoe89102f2017-02-15 23:18:15206Part of the linkgit:git[1] suite