@matheusbsbs / matheus-bagliano / commits / b8bc67cef3
Fork 0

cvs-migration documentation update

Here's some changes to the cvs-migration.txt. As usual, in my attempt to make things clearer someone may have found I've made them less so, or I may have just gotten something wrong; so any review is welcomed. I can break up this sort of thing into smaller steps if preferred, the monolothic patch is just a bit simpler for me for this sort of thing. I moved the material describing shared repository management from core-tutorial.txt to cvs-migration.txt, where it seems more appropriate, and combined two sections to eliminate some redundancy. I also revised the earlier sections of cvs-migration.txt, mainly trying to make it more concise. I've left the last section of cvs-migration.txt (on CVS annotate alternatives) alone for now. Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>

J. Bruce Fields committed Jan 28, 2006 at 23:31 UTC b8bc67cef31453233f1ff6722c0bd3c99df44756
2 files changed +163 -223
Documentation/core-tutorial.txt
+1 -117
@@ -1623,123 +1623,7 @@ suggested in the previous section may be new to you. You do not
1623 have to worry. git supports "shared public repository" style of
1624 cooperation you are probably more familiar with as well.
1625
1626 -For this, set up a public repository on a machine that is
1627 -reachable via SSH by people with "commit privileges". Put the
1628 -committers in the same user group and make the repository
1629 -writable by that group. Make sure their umasks are set up to
1630 -allow group members to write into directories other members
1631 -have created.
1632 -
1633 -You, as an individual committer, then:
1634 -
1635 -- First clone the shared repository to a local repository:
1636 -------------------------------------------------
1637 -$ git clone repo.shared.xz:/pub/scm/project.git/ my-project
1638 -$ cd my-project
1639 -$ hack away
1640 -------------------------------------------------
1641 -
1642 -- Merge the work others might have done while you were hacking
1643 - away:
1644 -------------------------------------------------
1645 -$ git pull origin
1646 -$ test the merge result
1647 -------------------------------------------------
1648 -[NOTE]
1649 -================================
1650 -The first `git clone` would have placed the following in
1651 -`my-project/.git/remotes/origin` file, and that's why this and
1652 -the next step work.
1653 -------------
1654 -URL: repo.shared.xz:/pub/scm/project.git/ my-project
1655 -Pull: master:origin
1656 -------------
1657 -================================
1658 -
1659 -- push your work as the new head of the shared
1660 - repository.
1661 -------------------------------------------------
1662 -$ git push origin master
1663 -------------------------------------------------
1664 -If somebody else pushed into the same shared repository while
1665 -you were working locally, `git push` in the last step would
1666 -complain, telling you that the remote `master` head does not
1667 -fast forward. You need to pull and merge those other changes
1668 -back before you push your work when it happens.
1669 -
1670 -The `git push` command without any explicit refspec parameter
1671 -pushes the refs that exist both in the local repository and the
1672 -remote repository. So the last `push` can be done with either
1673 -one of these:
1674 -------------
1675 -$ git push origin
1676 -$ git push repo.shared.xz:/pub/scm/project.git/
1677 -------------
1678 -as long as the shared repository does not have any branches
1679 -other than `master`.
1680 -[NOTE]
1681 -============
1682 -If you created your shared repository by cloning from somewhere
1683 -else, you may have the `origin` branch. Your developers
1684 -typically do not use that branch; remove it. Otherwise, that
1685 -would be pushed back by the `git push origin` because your
1686 -developers' repository would surely have `origin` branch to keep
1687 -track of the shared repository, and would be counted as "exist
1688 -on both ends".
1689 -============
1690 -
1691 -Advanced Shared Repository Management
1692 --------------------------------------
1693 -
1694 -Being able to push into a shared repository means being able to
1695 -write into it. If your developers are coming over the network,
1696 -this means you, as the repository administrator, need to give
1697 -each of them an SSH access to the shared repository machine.
1698 -
1699 -In some cases, though, you may not want to give a normal shell
1700 -account to them, but want to restrict them to be able to only
1701 -do `git push` into the repository and nothing else.
1702 -
1703 -You can achieve this by setting the login shell of your
1704 -developers on the shared repository host to `git-shell` program.
1705 -
1706 -[NOTE]
1707 -Most likely you would also need to list `git-shell` program in
1708 -`/etc/shells` file.
1709 -
1710 -This restricts the set of commands that can be run from incoming
1711 -SSH connection for these users to only `receive-pack` and
1712 -`upload-pack`, so the only thing they can do are `git fetch` and
1713 -`git push`.
1714 -
1715 -You still need to create UNIX user accounts for each developer,
1716 -and put them in the same group. Make sure that the repository
1717 -shared among these developers is writable by that group.
1718 -
1719 -. Initializing the shared repository with `git-init-db --shared`
1720 -helps somewhat.
1721 -
1722 -. Run the following in the shared repository:
1723 -+
1724 -------------
1725 -$ chgrp -R $group repo.git
1726 -$ find repo.git -type d -print | xargs chmod ug+rwx,g+s
1727 -$ GIT_DIR=repo.git git repo-config core.sharedrepository true
1728 -------------
1729 -
1730 -The above measures make sure that directories lazily created in
1731 -`$GIT_DIR` are writable by group members. You, as the
1732 -repository administrator, are still responsible to make sure
1733 -your developers belong to that shared repository group and set
1734 -their umask to a value no stricter than 027 (i.e. at least allow
1735 -reading and searching by group members).
1736 -
1737 -You can implement finer grained branch policies using update
1738 -hooks. There is a document ("control access to branches") in
1739 -Documentation/howto by Carl Baldwin and JC outlining how to (1)
1740 -limit access to branch per user, (2) forbid overwriting existing
1741 -tags.
1742 -
1626 +See link:cvs-migration.txt[git for CVS users] for the details.
1627
1628 Bundling your work together
1629 ---------------------------
Documentation/cvs-migration.txt
+162 -106
@@ -1,126 +1,182 @@
1 git for CVS users
2 =================
3
4 -Ok, so you're a CVS user. That's ok, it's a treatable condition, and the
5 -first step to recovery is admitting you have a problem. The fact that
6 -you are reading this file means that you may be well on that path
7 -already.
8 -
9 -The thing about CVS is that it absolutely sucks as a source control
10 -manager, and you'll thus be happy with almost anything else. git,
11 -however, may be a bit 'too' different (read: "good") for your taste, and
12 -does a lot of things differently.
13 -
14 -One particular suckage of CVS is very hard to work around: CVS is
15 -basically a tool for tracking 'file' history, while git is a tool for
16 -tracking 'project' history. This sometimes causes problems if you are
17 -used to doing very strange things in CVS, in particular if you're doing
18 -things like making branches of just a subset of the project. git can't
19 -track that, since git never tracks things on the level of an individual
20 -file, only on the whole project level.
21 -
22 -The good news is that most people don't do that, and in fact most sane
23 -people think it's a bug in CVS that makes it tag (and check in changes)
24 -one file at a time. So most projects you'll ever see will use CVS
25 -'as if' it was sane. In which case you'll find it very easy indeed to
26 -move over to git.
27 -
28 -First off: this is not a git tutorial. See
29 -link:tutorial.html[Documentation/tutorial.txt] for how git
30 -actually works. This is more of a random collection of gotcha's
31 -and notes on converting from CVS to git.
32 -
33 -Second: CVS has the notion of a "repository" as opposed to the thing
34 -that you're actually working in (your working directory, or your
35 -"checked out tree"). git does not have that notion at all, and all git
36 -working directories 'are' the repositories. However, you can easily
37 -emulate the CVS model by having one special "global repository", which
38 -people can synchronize with. See details later, but in the meantime
39 -just keep in mind that with git, every checked out working tree will
40 -have a full revision control history of its own.
4 +So you're a CVS user. That's ok, it's a treatable condition. The job of
5 +this document is to put you on the road to recovery, by helping you
6 +convert an existing cvs repository to git, and by showing you how to use a
7 +git repository in a cvs-like fashion.
8
9 +Some basic familiarity with git is required. This
10 +link:tutorial.html[tutorial introduction to git] should be sufficient.
11
43 -Importing a CVS archive
44 ------------------------
45 -
46 -Ok, you have an old project, and you want to at least give git a chance
47 -to see how it performs. The first thing you want to do (after you've
48 -gone through the git tutorial, and generally familiarized yourself with
49 -how to commit stuff etc in git) is to create a git'ified version of your
50 -CVS archive.
51 -
52 -Happily, that's very easy indeed. git will do it for you, although git
53 -will need the help of a program called "cvsps":
54 -
55 - http://www.cobite.com/cvsps/
56 -
57 -which is not actually related to git at all, but which makes CVS usage
58 -look almost sane (ie you almost certainly want to have it even if you
59 -decide to stay with CVS). However, git will want 'at least' version 2.1
60 -of cvsps (available at the address above), and in fact will currently
61 -refuse to work with anything else.
62 -
63 -Once you've gotten (and installed) cvsps, you may or may not want to get
64 -any more familiar with it, but make sure it is in your path. After that,
65 -the magic command line is
66 -
67 - git cvsimport -v -d <cvsroot> -C <destination> <module>
68 -
69 -which will do exactly what you'd think it does: it will create a git
70 -archive of the named CVS module. The new archive will be created in the
71 -subdirectory named <destination>; it'll be created if it doesn't exist.
72 -Default is the local directory.
12 +First, note some ways that git differs from CVS:
13
74 -It can take some time to actually do the conversion for a large archive
75 -since it involves checking out from CVS every revision of every file,
76 -and the conversion script is reasonably chatty unless you omit the '-v'
77 -option, but on some not very scientific tests it averaged about twenty
78 -revisions per second, so a medium-sized project should not take more
79 -than a couple of minutes. For larger projects or remote repositories,
80 -the process may take longer.
14 + * Commits are atomic and project-wide, not per-file as in CVS.
15
82 -After the (initial) import is done, the CVS archive's current head
83 -revision will be checked out -- thus, you can start adding your own
84 -changes right away.
16 + * Offline work is supported: you can make multiple commits locally,
17 + then submit them when you're ready.
18
86 -The import is incremental, i.e. if you call it again next month it'll
87 -fetch any CVS updates that have been happening in the meantime. The
88 -cut-off is date-based, so don't change the branches that were imported
89 -from CVS.
19 + * Branching is fast and easy.
20
91 -You can merge those updates (or, in fact, a different CVS branch) into
92 -your main branch:
21 + * Every working tree contains a repository with a full copy of the
22 + project history, and no repository is inherently more important than
23 + any other. However, you can emulate the CVS model by designating a
24 + single shared repository which people can synchronize with; see below
25 + for details.
26
94 - git resolve HEAD origin "merge with current CVS HEAD"
95 -
96 -The HEAD revision from CVS is named "origin", not "HEAD", because git
97 -already uses "HEAD". (If you don't like 'origin', use cvsimport's
98 -'-o' option to change it.)
99 -
100 -
101 -Emulating CVS behaviour
27 +Importing a CVS archive
28 -----------------------
29
30 +First, install version 2.1 or higher of cvsps from
31 +link:http://www.cobite.com/cvsps/[http://www.cobite.com/cvsps/] and make
32 +sure it is in your path. The magic command line is then
33 +
34 +-------------------------------------------
35 +$ git cvsimport -v -d <cvsroot> -C <destination> <module>
36 +-------------------------------------------
37 +
38 +This puts a git archive of the named CVS module in the directory
39 +<destination>, which will be created if necessary. The -v option makes
40 +the conversion script very chatty.
41 +
42 +The import checks out from CVS every revision of every file. Reportedly
43 +cvsimport can average some twenty revisions per second, so for a
44 +medium-sized project this should not take more than a couple of minutes.
45 +Larger projects or remote repositories may take longer.
46 +
47 +The main trunk is stored in the git branch named `origin`, and additional
48 +CVS branches are stored in git branches with the same names. The most
49 +recent version of the main trunk is also left checked out on the `master`
50 +branch, so you can start adding your own changes right away.
51 +
52 +The import is incremental, so if you call it again next month it will
53 +fetch any CVS updates that have been made in the meantime. For this to
54 +work, you must not modify the imported branches; instead, create new
55 +branches for your own changes, and merge in the imported branches as
56 +necessary.
57 +
58 +Development Models
59 +------------------
60 +
61 +CVS users are accustomed to giving a group of developers commit access to
62 +a common repository. In the next section we'll explain how to do this
63 +with git. However, the distributed nature of git allows other development
64 +models, and you may want to first consider whether one of them might be a
65 +better fit for your project.
66 +
67 +For example, you can choose a single person to maintain the project's
68 +primary public repository. Other developers then clone this repository
69 +and each work in their own clone. When they have a series of changes that
70 +they're happy with, they ask the maintainer to pull from the branch
71 +containing the changes. The maintainer reviews their changes and pulls
72 +them into the primary repository, which other developers pull from as
73 +necessary to stay coordinated. The Linux kernel and other projects use
74 +variants of this model.
75 +
76 +With a small group, developers may just pull changes from each other's
77 +repositories without the need for a central maintainer.
78 +
79 +Emulating the CVS Development Model
80 +-----------------------------------
81 +
82 +Start with an ordinary git working directory containing the project, and
83 +remove the checked-out files, keeping just the bare .git directory:
84 +
85 +------------------------------------------------
86 +$ mv project/.git /pub/repo.git
87 +$ rm -r project/
88 +------------------------------------------------
89 +
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].
95 +
96 +Put all the committers should in the same group, and make the repository
97 +writable by that group:
98 +
99 +------------------------------------------------
100 +$ chgrp -R $group repo.git
101 +$ find repo.git -mindepth 1 -type d |xargs chmod ug+rwx,g+s
102 +$ GIT_DIR=repo.git git repo-config core.sharedrepository true
103 +------------------------------------------------
104 +
105 +Make sure committers have a umask of at most 027, so that the directories
106 +they create are writable and searchable by other group members.
107 +
108 +Suppose this repository is now set up in /pub/repo.git on the host
109 +foo.com. Then as an individual commiter you can clone the shared
110 +repository:
111 +
112 +------------------------------------------------
113 +$ git clone foo.com:/pub/repo.git/ my-project
114 +$ cd my-project
115 +------------------------------------------------
116 +
117 +and hack away. The equivalent of `cvs update` is
118 +
119 +------------------------------------------------
120 +$ git pull origin
121 +------------------------------------------------
122 +
123 +which merges in any work that others might have done since the clone
124 +operation.
125 +
126 +[NOTE]
127 +================================
128 +The first `git clone` places the following in the
129 +`my-project/.git/remotes/origin` file, and that's why the previous step
130 +and the next step both work.
131 +------------
132 +URL: foo.com:/pub/project.git/ my-project
133 +Pull: master:origin
134 +------------
135 +================================
136 +
137 +You can update the shared repository with your changes using:
138
105 -So, by now you are convinced you absolutely want to work with git, but
106 -at the same time you absolutely have to have a central repository.
107 -Step back and think again. Okay, you still need a single central
108 -repository? There are several ways to go about that:
139 +------------------------------------------------
140 +$ git push origin master
141 +------------------------------------------------
142
110 -1. Designate a person responsible to pull all branches. Make the
111 -repository of this person public, and make every team member
112 -pull regularly from it.
143 +If some else has updated the repository more recently, `git push`, like
144 +`cvs commit`, will complain, in which case you must pull any changes
145 +before attempting the push again.
146
114 -2. Set up a public repository with read/write access for every team
115 -member. Use "git pull/push" as you used "cvs update/commit". Be
116 -sure that your repository is up to date before pushing, just
117 -like you used to do with "cvs commit"; your push will fail if
118 -what you are pushing is not up to date.
147 +In the `git push` command above we specify the name of the remote branch
148 +to update (`master`). If we leave that out, `git push` tries to update
149 +any branches in the remote repository that have the same name as a branch
150 +in the local repository. So the last `push` can be done with either of:
151
120 -3. Make the repository of every team member public. It is the
121 -responsibility of each single member to pull from every other
122 -team member.
152 +------------
153 +$ git push origin
154 +$ git push repo.shared.xz:/pub/scm/project.git/
155 +------------
156
157 +as long as the shared repository does not have any branches
158 +other than `master`.
159 +
160 +[NOTE]
161 +============
162 +Because of this behaviour, if the shared repository and the developer's
163 +repository both have branches named `origin`, then a push like the above
164 +attempts to update the `origin` branch in the shared repository from the
165 +developer's `origin` branch. The results may be unexpected, so it's
166 +usually best to remove any branch named `origin` from the shared
167 +repository.
168 +============
169 +
170 +Advanced Shared Repository Management
171 +-------------------------------------
172 +
173 +Git allows you to specify scripts called "hooks" to be run at certain
174 +points. You can use these, for example, to send all commits to the shared
175 +repository to a mailing list. See link:hooks.txt[Hooks used by git].
176 +
177 +You can enforce finer grained permissions using update hooks. See
178 +link:howto/update-hook-example.txt[Controlling access to branches using
179 +update hooks].
180
181 CVS annotate
182 ------------