interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / Documentation / gitcvs-migration.adoc

205 lines · 7734 bytes Raw Blame History
1gitcvs-migration(7)
2===================
3
4NAME
5----
6gitcvs-migration - Git for CVS users
7
8SYNOPSIS
9--------
10[verse]
11'git cvsimport' *
12
13DESCRIPTION
14-----------
15
16Git 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.
21
22Some basic familiarity with Git is required. Having gone through
23linkgit:gittutorial[7] and
24linkgit:gitglossary[7] should be sufficient.
25
26Developing against a shared repository
27--------------------------------------
28
29Suppose 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:
32
33------------------------------------------------
34$ git clone foo.com:/pub/repo.git/ my-project
35$ cd my-project
36------------------------------------------------
37
38and hack away. The equivalent of 'cvs update' is
39
40------------------------------------------------
41$ git pull origin
42------------------------------------------------
43
44which 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================================
50The 'pull' command knows where to get updates from because of certain
51configuration variables that were set by the first 'git clone'
52command; see the subcommand `list` in linkgit:git-config[1] for details.
53================================
54
55You can update the shared repository with your changes by first committing
56your changes, and then using the 'git push' command:
57
58------------------------------------------------
59$ git push origin master
60------------------------------------------------
61
62to "push" those commits to the shared repository. If someone else has
63updated the repository more recently, 'git push', like 'cvs commit', will
64complain, in which case you must pull any changes before attempting the
65push again.
66
67In 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
69any branches in the remote repository that have the same name as a branch
70in the local repository. So the last 'push' can be done with either of:
71
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,
84possibly created from scratch or from a tarball (see
85linkgit:gittutorial[7]), or imported from an already existing CVS
86repository (see the next section).
87
88Assume 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:
91
92------------------------------------------------
93$ mkdir /pub/my-repo.git
94$ cd /pub/my-repo.git
95$ git --bare init --shared
96$ git --bare fetch /home/alice/myproject master:master
97------------------------------------------------
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
103users to do Git pushes and pulls; see linkgit:git-shell[1].
104
105Put all the committers in the same group, and make the repository
106writable by that group:
107
108------------------------------------------------
109$ chgrp -R $group /pub/my-repo.git
110------------------------------------------------
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.
114
115Importing a CVS archive
116-----------------------
117
118NOTE: These instructions use the `git-cvsimport` script which ships with
119git, but other importers may provide better results. See the note in
120linkgit:git-cvsimport[1] for other options.
121
122First, install version 2.1 or higher of cvsps from
123https://github.com/andreyvit/cvsps[https://github.com/andreyvit/cvsps] and make
124sure it is in your path. Then cd to a checked out CVS working directory
125of the project you are interested in and run linkgit:git-cvsimport[1]:
126
127-------------------------------------------
128$ git cvsimport -C <destination> <module>
129-------------------------------------------
130
131This puts a Git archive of the named CVS module in the directory
132<destination>, which will be created if necessary.
133
134The import checks out from CVS every revision of every file. Reportedly
135cvsimport can average some twenty revisions per second, so for a
136medium-sized project this should not take more than a couple of minutes.
137Larger projects or remote repositories may take longer.
138
139The main trunk is stored in the Git branch named `origin`, and additional
140CVS branches are stored in Git branches with the same names. The most
141recent version of the main trunk is also left checked out on the `master`
142branch, so you can start adding your own changes right away.
143
144The import is incremental, so if you call it again next month it will
145fetch any CVS updates that have been made in the meantime. For this to
146work, you must not modify the imported branches; instead, create new
147branches for your own changes, and merge in the imported branches as
148necessary.
149
150If you want a shared repository, you will need to make a bare clone
151of the imported directory, as described above. Then treat the imported
152directory as another development clone for purposes of merging
153incremental imports.
154
155Advanced Shared Repository Management
156-------------------------------------
157
158Git allows you to specify scripts called "hooks" to be run at certain
159points. You can use these, for example, to send all commits to the shared
160repository to a mailing list. See linkgit:githooks[5].
161
162You can enforce finer grained permissions using update hooks. See
163link:howto/update-hook-example.html[Controlling access to branches using
164update hooks].
165
166Providing CVS Access to a Git Repository
167----------------------------------------
168
169It is also possible to provide true CVS access to a Git repository, so
170that developers can still use CVS; see linkgit:git-cvsserver[1] for
171details.
172
173Alternative Development Models
174------------------------------
175
176CVS users are accustomed to giving a group of developers commit access to
177a common repository. As we've seen, this is also possible with Git.
178However, the distributed nature of Git allows other development models,
179and you may want to first consider whether one of them might be a better
180fit for your project.
181
182For example, you can choose a single person to maintain the project's
183primary public repository. Other developers then clone this repository
184and each work in their own clone. When they have a series of changes that
185they're happy with, they ask the maintainer to pull from the branch
186containing the changes. The maintainer reviews their changes and pulls
187them into the primary repository, which other developers pull from as
188necessary to stay coordinated. The Linux kernel and other projects use
189variants of this model.
190
191With a small group, developers may just pull changes from each other's
192repositories without the need for a central maintainer.
193
194SEE ALSO
195--------
196linkgit:gittutorial[7],
197linkgit:gitdatamodel[7],
198linkgit:gitcore-tutorial[7],
199linkgit:gitglossary[7],
200linkgit:giteveryday[7],
201link:user-manual.html[The Git User's Manual]
202
203GIT
204---
205Part of the linkgit:git[1] suite