Remove uncontested renamed files during merge.
[git/debian.git] / Documentation / cvs-migration.txt
blobb657f4589f95257547b646ef22d3201fefbae6d6
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 committing
47 your changes, and then using the gitlink:git-push[1] command:
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 Assume your existing repo is at /home/alice/myproject.  Create a new "bare"
80 repository (a repository without a working tree) and fetch your project into
81 it:
83 ------------------------------------------------
84 $ mkdir /pub/my-repo.git
85 $ cd /pub/my-repo.git
86 $ git --bare init-db --shared
87 $ git --bare fetch /home/alice/myproject master:master
88 ------------------------------------------------
90 Next, give every team member read/write access to this repository.  One
91 easy way to do this is to give all the team members ssh access to the
92 machine where the repository is hosted.  If you don't want to give them a
93 full shell on the machine, there is a restricted shell which only allows
94 users to do git pushes and pulls; see gitlink:git-shell[1].
96 Put all the committers in the same group, and make the repository
97 writable by that group:
99 ------------------------------------------------
100 $ chgrp -R $group /pub/my-repo.git
101 ------------------------------------------------
103 Make sure committers have a umask of at most 027, so that the directories
104 they create are writable and searchable by other group members.
106 Importing a CVS archive
107 -----------------------
109 First, install version 2.1 or higher of cvsps from
110 link:http://www.cobite.com/cvsps/[http://www.cobite.com/cvsps/] and make
111 sure it is in your path.  Then cd to a checked out CVS working directory
112 of the project you are interested in and run gitlink:git-cvsimport[1]:
114 -------------------------------------------
115 $ git cvsimport -C <destination>
116 -------------------------------------------
118 This puts a git archive of the named CVS module in the directory
119 <destination>, which will be created if necessary.
121 The import checks out from CVS every revision of every file.  Reportedly
122 cvsimport can average some twenty revisions per second, so for a
123 medium-sized project this should not take more than a couple of minutes.
124 Larger projects or remote repositories may take longer.
126 The main trunk is stored in the git branch named `origin`, and additional
127 CVS branches are stored in git branches with the same names.  The most
128 recent version of the main trunk is also left checked out on the `master`
129 branch, so you can start adding your own changes right away.
131 The import is incremental, so if you call it again next month it will
132 fetch any CVS updates that have been made in the meantime.  For this to
133 work, you must not modify the imported branches; instead, create new
134 branches for your own changes, and merge in the imported branches as
135 necessary.
137 Advanced Shared Repository Management
138 -------------------------------------
140 Git allows you to specify scripts called "hooks" to be run at certain
141 points.  You can use these, for example, to send all commits to the shared
142 repository to a mailing list.  See link:hooks.html[Hooks used by git].
144 You can enforce finer grained permissions using update hooks.  See
145 link:howto/update-hook-example.txt[Controlling access to branches using
146 update hooks].
148 Providing CVS Access to a git Repository
149 ----------------------------------------
151 It is also possible to provide true CVS access to a git repository, so
152 that developers can still use CVS; see gitlink:git-cvsserver[1] for
153 details.
155 Alternative Development Models
156 ------------------------------
158 CVS users are accustomed to giving a group of developers commit access to
159 a common repository.  As we've seen, this is also possible with git.
160 However, the distributed nature of git allows other development models,
161 and you may want to first consider whether one of them might be a better
162 fit for your project.
164 For example, you can choose a single person to maintain the project's
165 primary public repository.  Other developers then clone this repository
166 and each work in their own clone.  When they have a series of changes that
167 they're happy with, they ask the maintainer to pull from the branch
168 containing the changes.  The maintainer reviews their changes and pulls
169 them into the primary repository, which other developers pull from as
170 necessary to stay coordinated.  The Linux kernel and other projects use
171 variants of this model.
173 With a small group, developers may just pull changes from each other's
174 repositories without the need for a central maintainer.