shortlog: fix segfault on empty authorname
[git/dscho.git] / Documentation / cvs-migration.txt
blob47846bdab266128af8a0d84f7c29963a4e54b845
1 git for CVS users
2 =================
4 Git differs from CVS in that every working tree contains a repository with
5 a full copy of the project history, and no repository is inherently more
6 important than any other.  However, you can emulate the CVS model by
7 designating a single shared repository which people can synchronize with;
8 this document explains how to do that.
10 Some basic familiarity with git is required.  This
11 link:tutorial.html[tutorial introduction to git] should be sufficient.
13 Developing against a shared repository
14 --------------------------------------
16 Suppose a shared repository is set up in /pub/repo.git on the host
17 foo.com.  Then as an individual committer you can clone the shared
18 repository over ssh with:
20 ------------------------------------------------
21 $ git clone foo.com:/pub/repo.git/ my-project
22 $ cd my-project
23 ------------------------------------------------
25 and hack away.  The equivalent of `cvs update` is
27 ------------------------------------------------
28 $ git pull origin
29 ------------------------------------------------
31 which merges in any work that others might have done since the clone
32 operation.  If there are uncommitted changes in your working tree, commit
33 them first before running git pull.
35 [NOTE]
36 ================================
37 The first `git clone` places the following in the
38 `my-project/.git/remotes/origin` file, and that's why the previous step
39 and the next step both work.
40 ------------
41 URL: foo.com:/pub/project.git/
42 Pull: refs/heads/master:refs/remotes/origin/master
43 ------------
44 ================================
46 You can update the shared repository with your changes by first commiting
47 your changes, and then using:
49 ------------------------------------------------
50 $ git push origin master
51 ------------------------------------------------
53 to "push" those commits to the shared repository.  If someone else has
54 updated the repository more recently, `git push`, like `cvs commit`, will
55 complain, in which case you must pull any changes before attempting the
56 push again.
58 In the `git push` command above we specify the name of the remote branch
59 to update (`master`).  If we leave that out, `git push` tries to update
60 any branches in the remote repository that have the same name as a branch
61 in the local repository.  So the last `push` can be done with either of:
63 ------------
64 $ git push origin
65 $ git push foo.com:/pub/project.git/
66 ------------
68 as long as the shared repository does not have any branches
69 other than `master`.
71 Setting Up a Shared Repository
72 ------------------------------
74 We assume you have already created a git repository for your project,
75 possibly created from scratch or from a tarball (see the
76 link:tutorial.html[tutorial]), or imported from an already existing CVS
77 repository (see the next section).
79 If your project's working directory is /home/alice/myproject, you can
80 create a shared repository at /pub/repo.git with:
82 ------------------------------------------------
83 $ git clone -bare /home/alice/myproject /pub/repo.git
84 ------------------------------------------------
86 Next, give every team member read/write access to this repository.  One
87 easy way to do this is to give all the team members ssh access to the
88 machine where the repository is hosted.  If you don't want to give them a
89 full shell on the machine, there is a restricted shell which only allows
90 users to do git pushes and pulls; see gitlink:git-shell[1].
92 Put all the committers in the same group, and make the repository
93 writable by that group:
95 ------------------------------------------------
96 $ cd /pub
97 $ chgrp -R $group repo.git
98 $ find repo.git -mindepth 1 -type d |xargs chmod ug+rwx,g+s
99 $ GIT_DIR=repo.git git repo-config core.sharedrepository true
100 ------------------------------------------------
102 Make sure committers have a umask of at most 027, so that the directories
103 they create are writable and searchable by other group members.
105 Importing a CVS archive
106 -----------------------
108 First, install version 2.1 or higher of cvsps from
109 link:http://www.cobite.com/cvsps/[http://www.cobite.com/cvsps/] and make
110 sure it is in your path.  The magic command line is then
112 -------------------------------------------
113 $ git cvsimport -v -d <cvsroot> -C <destination> <module>
114 -------------------------------------------
116 This puts a git archive of the named CVS module in the directory
117 <destination>, which will be created if necessary.  The -v option makes
118 the conversion script very chatty.
120 The import checks out from CVS every revision of every file.  Reportedly
121 cvsimport can average some twenty revisions per second, so for a
122 medium-sized project this should not take more than a couple of minutes.
123 Larger projects or remote repositories may take longer.
125 The main trunk is stored in the git branch named `origin`, and additional
126 CVS branches are stored in git branches with the same names.  The most
127 recent version of the main trunk is also left checked out on the `master`
128 branch, so you can start adding your own changes right away.
130 The import is incremental, so if you call it again next month it will
131 fetch any CVS updates that have been made in the meantime.  For this to
132 work, you must not modify the imported branches; instead, create new
133 branches for your own changes, and merge in the imported branches as
134 necessary.
136 Advanced Shared Repository Management
137 -------------------------------------
139 Git allows you to specify scripts called "hooks" to be run at certain
140 points.  You can use these, for example, to send all commits to the shared
141 repository to a mailing list.  See link:hooks.html[Hooks used by git].
143 You can enforce finer grained permissions using update hooks.  See
144 link:howto/update-hook-example.txt[Controlling access to branches using
145 update hooks].
147 Providing CVS Access to a git Repository
148 ----------------------------------------
150 It is also possible to provide true CVS access to a git repository, so
151 that developers can still use CVS; see gitlink:git-cvsserver[1] for
152 details.
154 Alternative Development Models
155 ------------------------------
157 CVS users are accustomed to giving a group of developers commit access to
158 a common repository.  As we've seen, this is also possible with git.
159 However, the distributed nature of git allows other development models,
160 and you may want to first consider whether one of them might be a better
161 fit for your project.
163 For example, you can choose a single person to maintain the project's
164 primary public repository.  Other developers then clone this repository
165 and each work in their own clone.  When they have a series of changes that
166 they're happy with, they ask the maintainer to pull from the branch
167 containing the changes.  The maintainer reviews their changes and pulls
168 them into the primary repository, which other developers pull from as
169 necessary to stay coordinated.  The Linux kernel and other projects use
170 variants of this model.
172 With a small group, developers may just pull changes from each other's
173 repositories without the need for a central maintainer.