~bzr-pqm/bzr/bzr.dev

2977.1.3 by Ian Clatworthy
1st cut at the 'Personal version control' chapter
1
Controlling file registration
2
=============================
3
4
What does Bazaar track?
5
-----------------------
6
7
As explained earlier, ``bzr add`` finds and registers all the things in
8
and under the current directory that Bazaar thinks ought to be
9
version controlled. These things may be:
10
11
 * files
12
 * directories
13
 * symbolic links.
14
15
Bazaar has default rules for deciding which files are
16
interesting and which ones are not. You can tune those rules as
17
explained in `Ignoring files`_ below.
18
3177.2.1 by Craig Fratrik
Fixed typo in User Guide
19
Unlike many other VCS tools, Bazaar tracks directories as first class
2977.1.3 by Ian Clatworthy
1st cut at the 'Personal version control' chapter
20
items. As a consequence, empty directories are correctly supported -
21
you don't need to create a dummy file inside a directory just to
22
ensure it gets tracked and included in project exports.
23
24
For symbolic links, the value of the symbolic link is tracked,
25
not the content of the thing the symbolic link is pointing to.
26
27
Note: Support for tracking projects-within-projects ("nested trees")
28
is currently under development. Please contact the Bazaar developers
29
if you are interested in helping develop or test this functionality.
30
31
Selective registration
32
----------------------
33
34
In some cases, you may want or need to explicitly nominate the things
35
to register rather than leave it up to Bazaar to find things. To do this,
36
simply provide paths as arguments to the ``add`` command like this::
37
38
  bzr add fileX dirY/
39
40
Adding a directory implicitly adds all interesting things
41
underneath it.
42
43
Ignoring files
44
--------------
45
46
Many source trees contain some files that do not need to be versioned,
47
such as editor backups, object or bytecode files, and built programs.  You
48
can simply not add them, but then they'll always crop up as unknown files.
49
You can also tell Bazaar to ignore these files by adding them to a file
50
called ``.bzrignore`` at the top of the tree.
51
52
This file contains a list of file wildcards (or "globs"), one per line.
53
Typical contents are like this::
54
55
    *.o
56
    *~
57
    *.tmp
58
    *.py[co]
59
60
If a glob contains a slash, it is matched against the whole path from the
61
top of the tree; otherwise it is matched against only the filename.  So
62
the previous example ignores files with extension ``.o`` in all
63
subdirectories, but this example ignores only ``config.h`` at the top level
64
and HTML files in ``doc/``::
65
66
    ./config.h
67
    doc/*.html
68
69
To get a list of which files are ignored and what pattern they matched,
70
use ``bzr ignored``::
71
72
    % bzr ignored
73
    config.h                 ./config.h
74
    configure.in~            *~
75
3350.2.1 by Martin Pool
Clearer explanation of ignore/add in user guide.
76
Note that ignore patterns are only matched against non-versioned files,
77
and control whether they are treated as "unknown" or "ignored".  If a file
78
is explicitly added, it remains versioned regardless of whether it matches
79
an ignore pattern.
2977.1.3 by Ian Clatworthy
1st cut at the 'Personal version control' chapter
80
81
The ``.bzrignore`` file should normally be versioned, so that new copies
82
of the branch see the same patterns::
83
84
    % bzr add .bzrignore
85
    % bzr commit -m "Add ignore patterns"
86
3373.3.1 by Neil Martinsen-Burrell
add bzr ignore to the Users Guide
87
The command ``bzr ignore PATTERN`` can be used to easily add PATTERN to
88
the ``.bzrignore file`` (creating it if necessary and registering it to
89
be tracked by Bazaar).  Removing and modifying patterns are done by
90
directly editing the ``.bzrignore`` file.
91
2977.1.3 by Ian Clatworthy
1st cut at the 'Personal version control' chapter
92
Global ignores
93
--------------
94
95
There are some ignored files which are not project specific, but more user
96
specific. Things like editor temporary files, or personal temporary files.
97
Rather than add these ignores to every project, bzr supports a global
98
ignore file in ``~/.bazaar/ignore`` [#]_. It has the same syntax as the
99
per-project ignore file.
100
101
.. [#] On Windows, the users configuration files can be found in the
102
   application data directory. So instead of ``~/.bazaar/branch.conf``
4853.1.1 by Patrick Regan
Removed trailing whitespace from files in doc directory
103
   the configuration file can be found as:
2977.1.3 by Ian Clatworthy
1st cut at the 'Personal version control' chapter
104
   ``C:\Documents and Settings\<username>\Application Data\Bazaar\2.0\branch.conf``.
105
   The same is true for ``locations.conf``, ``ignore``, and the
106
   ``plugins`` directory.