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