Fixed some typos
[git_nutshell_guides.git] / CVS2git.tex
blob5a5007b56c8613b64c948dbda6bfe2c1d6c8dfd8
1 \documentclass[a4paper,10pt]{article}
2 \usepackage[english]{babel}
3 \usepackage[OT1]{fontenc}
4 \usepackage[utf8]{inputenc}
5 \usepackage{fancyhdr}
6 \usepackage{mydoc}
7 \usepackage[pdftex,colorlinks=true,
8 pdfstartview=FitV,
9 linkcolor=blue,
10 citecolor=blue,
11 urlcolor=blue,
12 ]{hyperref}
14 \begin{document}
15 \pagestyle{fancy}
16 \fancyfoot{}
17 \fancyhead{}
18 \renewcommand{\sectionmark}[1]{\markboth{\sf\thesection.\ #1}{}}
19 \renewcommand{\subsectionmark}[1]{}
20 \fancyhead[R]{{\rmfamily\thepage}}
22 \title{CVS to git Transition Guide}
24 \subtitle{for Cold Turkey Quitters}
25 \author{{\sf Jonas Jus\'elius}}
26 \address{
27 {\tt <jonas.juselius@chem.uit.no>}\\
28 {\sf University of Tromsø}\\
29 {\sf Department of Chemistry}\\
30 {\sf N-9037 University of Tromsø, Norway}
32 \years{2007}
33 \abstract{Rev 0.3:\\{\tt git clone http://git.jonas.iki.fi/git\_guides.git}\\
34 Corrections and improvements are most welcome via e-mail using the
35 {\tt git format-patch} facility.}
37 \maketitle
38 \tableofcontents
39 \newpage
41 \section{Preliminaries}
42 This guide attempts to document one way of migrating both repositories and
43 users from CVS to git.
44 I'm sure there are many other equally good, or better, ways of doing
45 this. I have called my scheme the Cold Turkey scheme, since it involves
46 freezing CVS in one go, and moving to git without attempting any kind of soft
47 transition period operating both CVS and git in parallel.
49 This is not a git manual. There is a lot of decent
50 documentation available on the web, and all git commands are very well
51 documented, so there is no need to repeat them here.
52 This document explains step-by-step how to move your local changes
53 in your CVS repositories to the newly created git repository. It assumes that
54 you have a recent version of git installed on your system, and that you have
55 familiarised your self with the basic git operations by reading the available
56 git documentation at \url{http://git.or.cz}.
58 The first part of this guide is intended for repository administrators, and
59 documents step-by-step how to freeze the CVS archive and convert it to a git
60 archive.
62 The second part is intended for the individual developer, documenting how to
63 set up git for personal use, and how to safely migrate all uncommitted changes
64 from CVS to git.
66 \subsection{Recommended reading}
67 If you have not done so yet, I
68 recommend you start by reading the following two short tutorials:
69 \begin{description}
70 \item[Git for CVS users]:\\
71 \url{http://www.kernel.org/pub/software/scm/git/docs/cvs-migration.html}
72 \item[The git tutorial]:\\
73 \url{http://www.kernel.org/pub/software/scm/git/docs/tutorial.html}
74 \item[Git in a Nutshell]:\\
75 \url{http://git.jonas.iki.fi/gitweb.cgi?p=git_guides.git;a=tree}
76 \end{description}
77 Furthermore, the following documents may be of use:
78 \begin{description}
79 \item[Everyday git with 20 commands or so]:\\
80 \url{http://www.kernel.org/pub/software/scm/git/docs/everyday.html}
81 \item[Git user's manual]:\\
82 \url{http://www.kernel.org/pub/software/scm/git/docs/user-maunal.html}
83 \end{description}
85 \subsection{About this document}
86 This guide was written as part of moving the ACES2 (\url{http://www.aces2.de})
87 program package from CVS to git. As such it reflects the
88 practical choices made for this particular environment.
90 Finally, I'm sure there are errors and/or semi correct statements in this
91 document since I'm not a true git expert (yet). All suggestions and
92 corrections are welcome!
94 \subsection{Conventions}
95 I have used the following conventions in this document: Commands are written
96 in {\tt typewriter} and anything the user should replace with his/her own
97 options have been enclosed in brackets, e.g. {\tt <mybranch>}.
99 \section{Before you start}
100 This section is intended for administrators and users alike, and is based on
101 some of the experience of migrating a bunch of CVS users to git. It seems that
102 one of the main problems is for CVS users to grasp the distributed nature of
103 git, i.e. the difference between a commit and a push. Users can become very
104 confused, and think that git is impossibly complicated to use and understand.
106 The very nature of git makes it much more powerful than CVS. Git is allows for
107 a lot more flexibility, leading to a different workflow than under CVS.
108 Changing two both the source code revision software \emph{and} the working
109 paradigm at the same time is a recipe for trouble. It's not git itself that is
110 causing the confusion, rather the new way how to use it really efficiently! To
111 avoid having grumpy and confused users it's better to do one thing at a time.
112 Start by changing from CVS to git, but keep the same working paradigm as
113 before. When the users have become comfortable using git, you can implement
114 more advanced things like restricted branches and multiple remotes.
117 \section{Converting your CVS modules to git}
118 The general scheme used here for setting up the new git repository is based
119 in part on having a central master repository, CVS style, and in
120 part on providing centralised git hosting for the developers. The idea is to
121 provide the developers with as much comfort and fexibility as the like.
123 The central master server is set up with a master branch, which is supposed to
124 contain the latest, greatest, bleeding edge {\em working} development version
125 of the code. This is the branch from which the developers should pull
126 regularly, and only the repository maintainers have right to push to this
127 branch. There will also be an experimental branch to which people
128 can push code they want others to test. Furthermore there will be a testing
129 branch which acts as a staging area for code to be included in the master
130 branch. It's simple to have the code in the testing branch
131 pulled once per night and run through a test suite. If all tests pass,
132 the repository maintainers can merge with the master branch.
134 In addition to these standard branches, every user has the right to create and
135 update their own branch on the master server. One ``official'' branch per
136 developer is probably enough for most users. This simple setup allows users to
137 regularly fetch all remote branches and communicate code sideways if they need
138 to. If one branch is not enough, or if a developer has special requirements,
139 each developer is allowed to have his/hers own repository on the server. This
140 gives maximum flexibility to the users without losing too much transparency.
141 The git web interface shows all repositories in a directory tree, so that
142 everyone can follow the development cycle in all repositories.
144 \subsection{Overview}
145 To implement the Cold Turkey (tm) change to git, the following steps must be
146 taken
147 \begin{enumerate}
148 \item Decide where the new git repositories should reside
149 \item Create a UNIX group for the developers, one per project if necessary
150 \item Make the relevant CVS modules read-only
151 \item Convert the CVS repositories to git
152 \item Set permissions on files and directories
153 \item Set up the 'update' hook to enforce access restrictions
154 \item Lay back and enjoy a good days work
155 \end{enumerate}
157 \subsection{Staging for the switch}
158 Decide where you want the new repositories to reside, create the necessary
159 UNIX groups and set the permissions. Now is also a good time to fix
160 permissions on files. Source files should have {\tt chmod 644}, directories
161 and scripts should probably be {\tt chmod 755}.
162 \begin{verbatim}
163 $ mkdir /path/to/git
164 $ chgrp gits /path/to/git
165 $ chmod 775 /path/to/git
166 $ chmod +s /path/to/git
167 $ chmod +t /path/to/git
168 \end{verbatim}
170 Then change to your CVSROOT and make the module(s) read-only. Make sure that
171 the lock and history files remain in writable locations. These are configured
172 in \$CVSROOT/CVSROOT/config.
173 \begin{verbatim}
174 $ cd $CVSROOT
175 $ chmod -R ugo-w myproj
176 \end{verbatim}
177 Now CVS commits are disabled and the repository frozen.
179 \subsection{Converting the repository}
180 Converting a CVS repository with all branches, tags and the whole history is
181 very easy using {\tt git-cvsimport}.
182 Make sure you have a very recent version of git and cvsps installed, to avoid
183 unnecessary problems.
184 \begin{verbatim}
185 $ cd /path/to/git
186 $ git-cvsimport -k -i -d /path/to/CVSROOT -C myproj myproj
187 \end{verbatim}
188 To create a bare, shared repository we need to rename the git directory, fix
189 the permissions and edit the git config file
190 \begin{verbatim}
191 $ mv myproj/.git myproj.git
192 $ rmdir myproj
193 $ chgrp -R gitusers myproj.git
194 $ chmod -R ug+w myproj.git
195 $ chmod +s myproj.git
196 # the hooks/ and info/ dirs are special since the control repository access
197 $ cd myproj.git; chgrp -R gitadmin hooks info config description
198 $ find -type d -exec chmod +s {} \;
199 \end{verbatim}
200 Then edit the config file:
201 \begin{verbatim}
202 [core]
203 repositoryformatversion = 0
204 filemode = true
205 bare = true
206 sharedrepository = 1
207 [receive]
208 denyNonFastforwards = true
209 \end{verbatim}
210 Finally edit the description file, adding a one line comment comment
211 describing your project for gitweb.
213 \subsection{Access control}
214 To set up per user or group access restrictions, copy the
215 \texttt{update}\footnote{Distributed together with the source distribution of
216 this document.}
217 script to the hooks directory, fix the permissions and make sure it's
218 executable. Then copy the \texttt{allowed-users} and \texttt{allowed-groups}
219 files to the info directory. Fix the permissions and group ownership of these
220 files and edit to your liking. By default they give every developer the right
221 to have one personal branch and any number of personal tags at the master.
223 \subsection{Administrative details}
224 Git has two ways of storing objects in it's database, either as separate
225 files or in a packed format storing only differences between files. The packed
226 format is for many purposes more efficient than the default storage mode. It's
227 therefore a good idea to set up a cron job to traverse all git repositories on
228 the master server and run \texttt{git gc} once per night to pack and clean the
229 repositories. Obviously the cron job must be set up for a user which has
230 sufficient permissions in the repository tree. Edit and copy the git-optimize.sh
231 script distributed with this document to your git repository root directory
232 and make sure it's executable. Then set up the cron job to pack the
233 repositories
234 \begin{verbatim}
235 $ crontab -e
237 1 1 * * * cd /path/to/git; find -name "*.git" -type d -exec \
238 /path/to/git/git-optimize.sh {} \;
239 1 3 1 * * cd /path/to/git; find -name "*.git" -type d -exec \
240 /path/to/git/git-optimize.sh {} \;
241 \end{verbatim}
243 As a last point, it's a good idea to make sure that all users have a
244 \texttt{umask} of at least 027 to make sure that the files and directories are
245 accessible by all other developers.
247 \subsection{The web interface}
248 Git comes with a very nice and easy to set web interface. Visit
249 \url{http://repo.or.cz/w/git.git/} to see it action. I will not discuss how to
250 set up your web server, since there is ample information available on the web.
251 To install the web interface copy the gitweb.cgi script to a suitable
252 location (e.g. /usr/lib/cgi-bin on some systems) and edit the config file to
253 point to the right repository tree. The cgi-script will automatically pick up
254 all git projects under this tree. Please note that enabling the gitweb
255 interface also enables people to clone your repositories over http. This might
256 or might not be what you want, so it might be a good idea to set up access
257 restrictions on the web server so that only people you want can connect and
258 browse and clone your code. Your call.
260 \section{Migrating your local CVS repository}
262 \subsection{Before you start}
263 Before doing anything else, I suggest that you setup some default
264 configuration variables for git. Git uses a number of config files, system
265 wide, per user and per repository (see the git config man page for more info).
266 As a minimum you should set the following options:
267 \begin{verbatim}
268 $ git config --global user.name "Your Name"
269 $ git config --global user.email "my@email.com"
270 \end{verbatim}
271 These options are written in ~/.gitconfig, and are used by git to ensure that
272 your commit messages are sensible, since user names and mail addresses are not
273 necessarily set properly on all machines. In addition you might want to enable
274 the following options as well:
275 \begin{verbatim}
276 $ git config --global color.branch auto
277 $ git config --global color.status auto
278 $ git config --global color.diff false
279 \end{verbatim}
280 If you want to use some external (graphical) merge tool to resolve conflicts:
281 \begin{verbatim}
282 $ git config --global merge.tool meld
283 \end{verbatim}
284 Meld is a fantastic merge tool, and I strongly suggest you have a look at it.
285 Other valid possibilities are kdiff3 and xxdiff (amongst others).
287 \subsection{Updating your CVS repository}
288 Since the old CVS server is no longer accepting new modifications, you need to
289 move all of your local modifications under git and then commit them. To do
290 this you need to follow these directions carefully. Before you start I
291 strongly suggest that you backup your working copy!
292 \begin{description}
293 \item[Update] The first thing you must do is to synchronise your working
294 copy with the CVS server by running
295 \begin{verbatim}
296 $ cvs update
297 \end{verbatim}
298 This makes sure that your files are in the right state.
299 Files with local modifications will not be overwritten nor
300 updated. If you have modified files that meanwhile have been modified on the
301 master you will probably have a number of conflicts. You need to resolve these
302 conflicts before continuing. Edit the files with conflicts and pick the
303 correct pieces of code between the markers.
304 \item[Diff] The next step is to create a patch file to migrate all your
305 changes from CVS to your new git repository.
306 Now that all files, except your locally modified files, are in the same state
307 as on the master you can run
308 \begin{verbatim}
309 $ cvs diff -u -N >migration.diff
310 \end{verbatim}
311 This file contains all the differences between the master and your working
312 copy.
313 \end{description}
315 \subsection{Setting up the git repository}
316 \begin{description}
317 \item[Clone] Now you are in a position to clone the new git master repository!
318 Change your working directory to where you want to create your new repository
319 and run
320 \begin{verbatim}
321 $ git clone <myserver>:/path/to/repos/myrepo.git
322 $ cd aces2
323 \end{verbatim}
324 Optionally you can also specify the name of the new repository.
325 \item[Branch and checkout]
326 Before you do anything else you need to create a new (local) branch which is
327 in the same state as the old master CVS, and switch to the new branch. The new
328 branch will be called migration (or whatever) and must be created from the tag
329 CVS\_migration\_HEAD:
330 \begin{verbatim}
331 $ git branch migration CVS_migration_HEAD
332 $ git checkout migration
333 \end{verbatim}
334 \item[Patch] You are now ready to apply the patch you created and bring your
335 own local modifications into your git repository
336 \begin{verbatim}
337 $ patch -p0 < /path/to/myproj/migration.diff
338 \end{verbatim}
339 The patch should apply without a hitch if you have done everything correctly.
340 You can now run
341 \begin{verbatim}
342 $ git status
343 \end{verbatim}
344 to show the status of your repository (i.e. modified files, deleted files,
345 files that needs to be added, etc.).
346 \end{description}
348 Congratulations! Your repository is now in the same state as before the
349 switch!
351 \subsection{Committing your changes}
352 The following step in the migration process is to commit all
353 your changes in your local repository. Don't worry, you will not mess up
354 anything on the master, or even make your changes public yet. This is a
355 personal commit so far.
357 Before you add changes (and files) to
358 commit you should probably think closely about how changes are logically
359 related and how they could be grouped into sets, instead of committing
360 everything as one big blob. It's better to have many, many small commits than
361 a few big ones, since this helps picking out particular patch sets and
362 applying them to other branches (this is known as cherry picking).
363 There is a convenient tool to pick, group and commit
364 your changes
365 \begin{verbatim}
366 $ git citool
367 \end{verbatim}
368 If you rather do everything by hand, repeatedly run
369 \begin{verbatim}
370 $ git add file(s)
371 $ git commit
372 \end{verbatim}
373 to group changes into sets, until all changes have been committed.
374 This is also how you add untracked files to git.
376 Finally run
377 \begin{verbatim}
378 $ git status
379 \end{verbatim}
380 to check that you have not missed anything.
382 You can also just run
383 \begin{verbatim}
384 $ git commit -a
385 \end{verbatim}
386 to do what you probably should not, i.e. commit everything as one huge commit.
389 \section{Getting started with git}
390 Ok, so now all your changes have been safely committed in your local
391 repository. The big difference to CVS is that commits are not automatically
392 communicated to the master server. How to communicate your changes to the
393 master will depend on how the master has been set up. The two following
394 sections will explain how to get started with git, and how to communicate with
395 the master repository.
397 \subsection{Using git like CVS}
398 Here I will outline how to use git in a CVS-like fashion, without having
399 to bother with branches and other complications. For completeness I have
400 included how to clone a repository.
401 The corresponding cvs commands are included as an example.
403 \begin{enumerate}
404 \item To get a local copy of the source repository:
405 \begin{verbatim}
406 [ cvs checkout -d :ext:mylogin@myserver:/path/to/CVSROOT myproj ]
407 $ git clone mylogin@myserver:/path/to/repository/myproj.git
408 \end{verbatim}
410 \item Updating the source repository to get the latest changes from the
411 master:
412 \begin{verbatim}
413 [ cvs update ]
414 $ git pull origin master
415 \end{verbatim}
417 \item Checking in your changes on the master:
418 \begin{verbatim}
419 [ cvs update ]
420 [ cvs checkin file1 file2 ...]
422 $ git pull origin
423 $ git commit file1 file2 ...
424 $ git push origin master
425 \end{verbatim}
427 This is where git differs from CVS substantially, committing a file
428 commits it to your local repository, and pushing it transfers it to the
429 master. Note that before you can push anything it has to be committed!
430 A more useful way of working is:
431 \begin{verbatim}
432 ... work
433 $ git commit file1 file2 ...
434 ... work
435 $ git commit fileN dir2 ...
436 ... work
437 $ git commit -a # (commits everything)
438 ... ok, we are ready with a new feature
439 $ git pull origin master
440 $ git push origin master
441 \end{verbatim}
443 If you get a conflict when you pull, please consult the Nutshell guide
444 how to resolve it.
446 \item Common tasks:
447 \begin{enumerate}
448 \item How to add a file:
449 \begin{verbatim}
450 [ cvs add file1 ... ]
451 $ git add file1 ...
452 \end{verbatim}
454 \item How to delete a file:
455 \begin{verbatim}
456 [ cvs remove file1 ]
457 $ git rm file1
458 \end{verbatim}
460 \item How to move or rename a file:
461 \begin{verbatim}
462 [ CVS cannot do this ]
463 $ git mv file1 file2
464 \end{verbatim}
466 \item How to restore a file which you have deleted:
467 \begin{verbatim}
468 [ cvs update ]
469 $ git checkout file1
470 \end{verbatim}
471 \end{enumerate}
472 \end{enumerate}
474 \subsection{Git vs. CVS}
475 Git is not very different from CVS for everyday use, although it may at first
476 seem so! There are really only two things that differ dramatically from CVS;
477 your working copy is a full repository, hence the separation of making a
478 commit and communicating the commit(s). The other big difference is that git
479 keeps track of the state of a whole repository, not single files.
481 It's important to understand that a commit under git is exactly the same thing
482 as under CVS, even if it's local to you until you push. When you push git
483 will update the remote branch (master in this case) to be in the exact same
484 state as your repository. This means that if you have 12 commits which are not
485 on the remote server, then all those 12 commits will be communicated! Under
486 CVS you would have made 12 commits directly to the server, under git you can
487 commit any number of times, and when you think it's appropriate you push them
488 all in one batch to the server.
490 In the old, comfy realm of CVS you would work, work, work
491 and never commit until you had something you really needed or had to
492 commit, like a bugfix in one file in some module. You can do exactly the same
493 with git! Never commit anything until you have something you really
494 need to commit. Then you do the following:
496 \begin{verbatim}
497 # first make sure we are up-to-date
498 $ git pull origin master
499 # commit CVS style
500 $ git commit file1 file2 ... fileN
501 $ git push origin master
502 \end{verbatim}
504 This is identical behaviour compared to CVS, except for the fact that you
505 explicitly need to communicate the changes to your 'origin'.
507 Of course, now I will argue that working like in the old CVS world is
508 not very good. For one thing, it's important to commit often, since
509 this way you get a much better work log/history and it's makes tracking
510 down bugs a lot easier. Furthermore, when you accidentally delete a
511 file, you can always get a reasonably new version back (if you have no
512 daily backups of your work area).
514 Now the problem arises; you need to publish a small fix, but you have a
515 lot of commits, and the code is not ready for the public yet. This is
516 one place where branches are very convenient:
517 \begin{itemize}
518 \item If you have not fixed the
519 problem yet, create a new temporary branch (call it fix or whatever),
520 checkout the branch, fix the problem, commit, push to the master,
521 checkout your working branch, pull the fix from the master, delete the
522 fix branch.
523 \item On the other hand, if you already have fixed and committed
524 the fix, the procedure is almost the same, but with one difference:
525 Create and checkout the fix branch, use 'gitk' or 'git log' to find the
526 SHA1-number of the commit which fixed the problem, then use 'git
527 cherry-pick SHA1-number' to incorporate that commit and nothing else
528 into the fix branch, push to the master, checkout the working branch and
529 delete the fix branch.
530 \end{itemize}
532 \subsection{Working with remote servers}
533 In the setup outlined above, every developer has the
534 possibility to cerate their own branch on the master (note that it's not
535 created by default). You can only commit branches and tags which have names
536 that start with your user id.
538 \subsubsection{Creating a remote branch}
539 To create a new branch on a remote server, git
540 requires a very explicit syntax. After you have created the branch, you can
541 use the same syntax as when operating on local branches. To create a remote
542 branch and push your changes in the migration branch to it, do
543 \begin{verbatim}
544 $ git push origin migration:refs/heads/<muid>
545 \end{verbatim}
546 where {\tt <myuid>} is your login on the server.
548 \subsubsection{Fetching changes}
549 To follow what others are doing and incorporating
550 their latest changes you need to regularly fetch their changes. git is very
551 flexible in the ways you can do things, so consult the man pages for more
552 info. To download all changes from the master run
553 \begin{verbatim}
554 $ git fetch origin
555 \end{verbatim}
556 This downloads all remote branches and stores them in your remote tracking
557 branches (use {\tt git branch -r} to see them). {\tt git fetch} does not merge any changes
558 into your working branches. After the git fetch you can examine the changes to
559 the remote branches using e.g. {\tt gitk --all} or
560 {\tt git [log/diff] origin/master}.
561 To update your current branch with e.g. the remote master branch do
562 \begin{verbatim}
563 $ git merge origin/master
564 \end{verbatim}
566 \subsubsection{Pulling changes}
567 There is a much easier way of updating your branches
568 from the master server:
569 \begin{verbatim}
570 $ git pull origin master
571 \end{verbatim}
572 This command automatically fetches the master branch from the server and
573 merges it with your current branch. This is more or less the git equivalent of
574 {\tt cvs update}. Note that this only fetches the specified branch from the
575 server. If you want all changes on all branches use the fetch command above.
577 \subsubsection{Push}
578 To publish changes to a branch so that others can see them and
579 alternatively merge them with their branches you must push them to the main
580 server. This is in a sense the git equivalent of a {\tt cvs commit}.
581 To upload a
582 branch and merge it with your personal branch on the server, do
583 \begin{verbatim}
584 $ git push origin somebranch:<myuid>
585 \end{verbatim}
586 For more details see the git push man page. Note that for a push to work, it
587 must result in a so called fast-forward-merge. Fast-forward means that the
588 files you want to merge on another branch, must have the files in the other
589 branch as parents. Simply stated, the files on the other branch have not
590 changed since the last pull. If the push fails because it's not fast-forward,
591 you must first do a {\tt git pull origin branch} and resolve any conflicts
592 before
593 (re)doing the push.
595 \subsubsection{Tagging}
596 To create a tag, simply run {\tt git tag <tagname>}. To push
597 your tags to the main server, do
598 \begin{verbatim}
599 $ git push --tags origin
600 \end{verbatim}
601 This will push all your tags to the main server. Note that you are not allowed
602 by the server to create tags unless they are prefixed with your user id, e.g.
603 {\tt <myuid>/mytag}. If you don't want to push all tags, you can use the special
604 syntax
605 \begin{verbatim}
606 $ git push origin tag <myuid>/<mytag>
607 \end{verbatim}
608 To delete a tag on the master you need to explicitly push an empty tag
609 \begin{verbatim}
610 $ git push origin :refs/tags/<myuid>/<mytag>
611 \end{verbatim}
613 \subsubsection{Deleting a remote branch}
614 If you for some reason want to delete a branch
615 on the remote server, just push an empty branch to the remote branch:
616 \begin{verbatim}
617 $ git push origin :<branch>
618 \end{verbatim}
620 Since branches come and go, both in {\tt origin} and in your own remote(s)
621 it's a good idea to clean up the remotes once in a while by doing a
622 \begin{verbatim}
623 $ git remote prune origin
624 \end{verbatim}
626 \subsection{Adding a remote repository}
627 If you want to have more
628 flexibility, more branches and tags (on the server) and more freedom
629 generally, you can also set up your own personal repository on the master. git
630 makes it quite easy to work with multiple remote repositories in one go.
632 To set up your own sub-master repository follow these steps:
633 \begin{verbatim}
634 $ ssh <myserver>
635 $ cd /path/to/repos
636 $ mkdir $USER
637 $ git clone -s -l --bare proj.git $USER/proj.git
638 $ cd $USER/proj.git
639 $ git branch -a
640 # remove any branches and tags you do not care about
641 $ git branch -D <branch branch...>
642 $ git tag -d <tag tag...>
643 # edit description (for gitweb) to your liking
644 $ vi description
645 \end{verbatim}
646 The -s and -l options to {\tt git clone} will cause git to set up the
647 repository to use the master's object database as much as possible, so that it
648 will take up very little space.
650 Now on your local machine, cd to your development repository and register the
651 new remote:
652 \begin{verbatim}
653 $ git remote add <name> <myserver>:/path/to/repos/<myuid>/proj.git
654 \end{verbatim}
655 Now when you fetch, pull and push use your new remote-tag {\tt <name>} instead
656 of {\tt origin} to the corresponding command. The new development cycle will
657 typically be something like
658 \begin{verbatim}
659 $ git pull origin master
660 # do some work
661 $ git push myremote mybranch:mybranch
662 # or to push all branches automatically
663 $ git push --all myremote
664 \end{verbatim}
666 \section{Useful git commands}
667 Here is a short list of useful git commands to familiarise yourself with when
668 you feel that you have the basics under control. {\tt man git-<command>} will
669 give you all available information on a particular command.
670 \begin{description}
671 \item{\tt gitk} Graphical interface for browsing repositories.
672 \item{\tt qgit} Graphical interface for browsing repositories. Better and more
673 advance than gitk, but probably not installed on your system by default.
674 \item{\tt git diff} View differences between your working copy and a committed
675 revision (and more).
676 \item{\tt git gc} By default git will store all objects in a very primitive
677 and storage inefficient way. This command packs, compresses and prunes
678 unreachable objects in the object database. {\bf Should be used regularly}.
679 \item{\tt git stash} If you need to checkout a new branch, but don't want to
680 commit your changes, stash allows you to temporarily save your changes. Only
681 in git 1.5.3 and newer.
682 \item{\tt git cherry-pick} Instead of merging two complete branches, only pick the
683 commits you really want from a branch.
684 \item{\tt git bisect} Find a commit which introduced some nasty bug. Very
685 helpful.
686 \item{\tt git log} View the commit history on a branch
687 \item{\tt git archive} Create a tar or zip archive from a branch.
688 \item{\tt git mv} Rename files in the repository.
689 \item{\tt git rm} Delete files from the repository.
690 \item{\tt git annotate} Show who changed what and when in files.
691 \item{\tt git format-patch} Generate an patch file of a commit, suitable for
692 sending by e-mail
693 \item{\tt git am} Apply a patch from a mailbox
695 \end{description}
697 \end{document}