Skip to content

Commit ed716b3

Browse files
committed
Merge branch 'remove_UTF8_BOM' into master
2 parents 81e1d26 + 1f92acc commit ed716b3

File tree

7 files changed

+282
-5
lines changed

7 files changed

+282
-5
lines changed

book/01-introduction/sections/installing.asc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ The most official build is available for download on the Git website.
5656
Just go to http://git-scm.com/download/win[] and the download will start automatically.
5757
Note that this is a project called Git for Windows, which is separate from Git itself; for more information on it, go to https://git-for-windows.github.io/[].
5858

59+
To get an automated installation you can use the https://chocolatey.org/packages/git[Git Chocolatey package].
60+
Note that the Chocolatey package is community maintained.
61+
5962
Another easy way to get Git installed is by installing GitHub for Windows.
6063
The installer includes a command line version of Git as well as the GUI.
6164
It also works well with Powershell, and sets up solid credential caching and sane CRLF settings.(((Powershell)))(((CRLF)))(((credential caching)))

book/09-git-and-other-scms/1-git-and-other-scms.asc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ include::sections/client-svn.asc[]
1919

2020
include::sections/client-hg.asc[]
2121

22+
include::sections/client-bzr.asc[]
23+
2224
include::sections/client-p4.asc[]
2325

2426
include::sections/client-tfs.asc[]
@@ -35,6 +37,8 @@ include::sections/import-svn.asc[]
3537

3638
include::sections/import-hg.asc[]
3739

40+
include::sections/import-bzr.asc[]
41+
3842
include::sections/import-p4.asc[]
3943

4044
include::sections/import-tfs.asc[]
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
==== Git and Bazaar
2+
3+
Among the DVCS, another famous one is http://bazaar.canonical.com/[Bazaar].
4+
Bazaar is free and open source, and is part of the http://www.gnu.org/[GNU Project].
5+
It behaves very differently from Git.
6+
Sometimes, to do the same thing as with Git, you have to use a different keyword, and some keywords that are common don't have the same meaning.
7+
In particular, the branch management is very different and may cause confusion, especially when someone comes from Git's universe.
8+
Nevertheless, it is possible to work on a Bazaar repository from a Git one.
9+
10+
There are many projects that allow you to use Git as a Bazaar client.
11+
Here we'll use Felipe Contreras' project that you may find at https://github.com/felipec/git-remote-bzr[].
12+
To install it, you just have to download the file git-remote-bzr in a folder contained in your `$PATH`:
13+
[source,console]
14+
----
15+
$ wget https://raw.github.com/felipec/git-remote-bzr/master/git-remote-bzr -O ~/bin/git-remote-bzr
16+
$ chmod +x ~/bin/git-remote-bzr
17+
----
18+
19+
You also need to have Bazaar installed.
20+
That's all!
21+
22+
===== Create a Git repository from a Bazaar repository
23+
24+
It is simple to use.
25+
It is enough to clone a Bazaar repository prefixing it by `bzr::`.
26+
Since Git and Bazaar both do full clones to your machine, it's possible to attach a Git clone to your local Bazaar clone, but it isn't recommended.
27+
It's much easier to attach your Git clone directly to the same place your Bazaar clone is attached to ‒ the central repository.
28+
29+
Let's suppose that you worked with a remote repository which is at address `bzr+ssh://developer@mybazaarserver:myproject`.
30+
Then you must clone it in the following way:
31+
[source,console]
32+
----
33+
$ git clone bzr::bzr+ssh://developer@mybazaarserver:myproject myProject-Git
34+
$ cd myProject-Git
35+
----
36+
37+
At this point, your Git repository is created but it is not compacted for optimal disk use.
38+
That's why you should also clean and compact your Git repository, especially if it is a big one:
39+
[source,console]
40+
----
41+
$ git gc --aggressive
42+
----
43+
44+
===== Bazaar branches
45+
46+
Bazaar only allows you to clone branches, but a repository may contain several branches, and `git-remote-bzr` can clone both.
47+
For example, to clone a branch:
48+
[source,console]
49+
----
50+
$ git clone bzr::bzr://bzr.savannah.gnu.org/emacs/trunk emacs-trunk
51+
----
52+
53+
And to clone the whole repository:
54+
[source,console]
55+
----
56+
$ git clone bzr::bzr://bzr.savannah.gnu.org/emacs emacs
57+
----
58+
59+
The second command clones all the branches contained in the emacs repository; nevertheless, it is possible to point out some branches:
60+
[source,console]
61+
----
62+
$ git config remote-bzr.branches 'trunk, xwindow'
63+
----
64+
65+
Some remote repositories don't allow to list their branches, in which case you have to manually specify them, and even though you could specify the configuration in the cloning command, you may find this easier:
66+
67+
[source,console]
68+
----
69+
$ git init emacs
70+
$ git remote add origin bzr::bzr://bzr.savannah.gnu.org/emacs
71+
$ git config remote-bzr.branches 'trunk, xwindow'
72+
$ git fetch
73+
----
74+
75+
===== Ignore what is ignored with .bzrignore
76+
77+
As the format of the `.bzrignore` file is completely compatible with `.gitignore`'s one, and as you shouldn't make a `.gitignore` file in your repository, it is enough to make a symbolic link to `.bzrignore` so that the potential changes of `.bzrignore` are taken into account:
78+
[source,console]
79+
----
80+
$ ln -s .bzrignore .git/info/exclude
81+
----
82+
83+
===== Fetch the changes of the remote repository
84+
85+
To fetch the changes of the remote, you pull changes as usually, using Git commands.
86+
Supposing that your changes are on the `master` branch, you merge or rebase your work on the `origin/master` branch:
87+
[source,console]
88+
----
89+
$ git pull --rebase origin
90+
----
91+
92+
===== Push your work on the remote repository
93+
94+
Because Bazaar also has the concept of merge commits, there will be no problem if you push a merge commit.
95+
So you can work on a branch, merge the changes into `master` and push your work.
96+
Then, you create your branches, you test and commit your work as usual.
97+
You finally push your work to the Bazaar repository:
98+
[source,console]
99+
----
100+
$ git push origin master
101+
----
102+
103+
===== Caveats
104+
105+
Git's remote-helpers framework has some limitations that apply.
106+
In particular, these commands don't work:
107+
108+
* git push origin :branch-to-delete (Bazaar can't accept ref deletions in this way.)
109+
* git push origin old:new (it will push 'old')
110+
* git push --dry-run origin branch (it will push)
111+
112+
===== Summary
113+
114+
Since Git's and Bazaar's models are similar, there isn't a lot of resistance when working across the boundary.
115+
As long as you watch out for the limitations, and are always aware that the remote repository isn't natively Git, you'll be fine.
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
==== Bazaar
2+
(((Bazaar)))(((Importing, from Bazaar)))
3+
4+
Bazaar is a DVCS tool much like Git, and as a result it's pretty straightforward to convert a Bazaar repository into a Git one.
5+
To accomplish this, you'll need to import the `bzr-fastimport` plugin.
6+
7+
8+
===== Getting the bzr-fastimport plugin
9+
10+
The procedure for installing the fastimport plugin is different on UNIX-like operating systems and on Windows.
11+
In the first case, the simplest is to install the `bzr-fastimport` package that will install all the required dependencies.
12+
13+
For example, with Debian and derived, you would do the following:
14+
[source,console]
15+
----
16+
$ sudo apt-get install bzr-fastimport
17+
----
18+
19+
With RHEL, you would do the following:
20+
[source,console]
21+
----
22+
$ sudo yum install bzr-fast-import
23+
----
24+
25+
With Fedora, since release 22, the new package manager is dnf:
26+
[source,console]
27+
----
28+
$ sudo dnf install bzr-fastimport
29+
----
30+
31+
If the package is not available, you may install it as a plugin:
32+
[source,console]
33+
----
34+
$ mkdir --parents ~/.bazaar/plugins/bzr # creates the necessary folders for the plugins
35+
$ cd ~/.bazaar/plugins/bzr
36+
$ bzr branch lp:bzr-fastimport fastimport # imports the fastimport plugin
37+
$ cd fastimport
38+
$ sudo python setup.py install --record=files.txt # installs the plugin
39+
----
40+
41+
For this plugin to work, you'll also need the `fastimport` Python module.
42+
You can check whether it is present or not and install it with the following commands:
43+
[source,console]
44+
----
45+
$ python -c "import fastimport"
46+
Traceback (most recent call last):
47+
File "<string>", line 1, in <module>
48+
ImportError: No module named fastimport
49+
$ pip install fastimport
50+
----
51+
If it is not available, you can download it at address https://pypi.python.org/pypi/fastimport/.
52+
53+
In the second case (on Windows), `bzr-fastimport` is automatically installed with the standalone version and the default installation (let all the checkboxes checked).
54+
So in this case you have nothing to do.
55+
56+
At this point, the way to import a Bazaar repository differs according to that you have a single branch or you are working with a repository that has several branches.
57+
58+
===== Project with a single branch
59+
60+
Now `cd` in the directory that contains your Bazaar repository and initialize the Git repository:
61+
[source,console]
62+
----
63+
$ cd /path/to/the/bzr/repository
64+
$ git init
65+
----
66+
67+
Now, you can simply export your Bazaar repository and convert it into a Git repository using the following command:
68+
[source,console]
69+
----
70+
$ bzr fast-export --plain . | git fast-import
71+
----
72+
73+
Depending on the size of the project, your Git repository is built in a lapse from a few seconds to a few minutes.
74+
75+
At this point, the `.git` directory and your working tree are all set up, but Git's index isn't synchronised with the working tree:
76+
[source,console]
77+
----
78+
$ git status
79+
On master branch
80+
Changes that will be validated:
81+
(use "git reset HEAD <fichier>..." to unstage)
82+
83+
removed : .bzrignore
84+
removed : file.txt
85+
86+
Untracked files:
87+
(use "git add <fichier>..." to include in what will be validated)
88+
89+
.bzr/
90+
.bzrignore
91+
file.txt
92+
----
93+
Type this to fix that:
94+
[source,console]
95+
----
96+
$ git reset HEAD .
97+
----
98+
99+
Now let us have a look at the files to ignore.
100+
As `.bzrignore`'s format is completely compatible with `.gitignore`'s format, the simplest is to rename your `.bzrignore` file:
101+
[source,console]
102+
----
103+
$ git mv .bzrignore .gitignore
104+
----
105+
106+
Then you have to create a commit that contains this change for the migration:
107+
[source,console]
108+
----
109+
$ git commit -am 'Migration from Bazaar to Git'
110+
----
111+
112+
That's all!
113+
Now you can push the repository onto its new home server:
114+
[source,console]
115+
----
116+
$ git remote add origin git@my-git-server:mygitrepository.git
117+
$ git push origin --all
118+
$ git push origin --tags
119+
----
120+
121+
===== Case of a project with a main branch and a working branch
122+
123+
You can also import a Bazaar repository that contains branches.
124+
Let us suppose that you have two branches: one represents the main branch (myProject.trunk), the other one is the working branch (myProject.work).
125+
[source,console]
126+
----
127+
$ ls
128+
myProject.trunk myProject.work
129+
----
130+
131+
Create the Git repository and `cd` into it:
132+
[source,console]
133+
----
134+
$ git init git-repo
135+
$ cd git-repo
136+
----
137+
138+
Pull the master branch into git:
139+
[source,console]
140+
----
141+
$ bzr fast-export --export-marks=../marks.bzr ../myProject.trunk | \
142+
git fast-import --export-marks=../marks.git
143+
----
144+
145+
Pull the working branch into Git:
146+
[source,console]
147+
----
148+
$ bzr fast-export --marks=../marks.bzr --git-branch=work ../myProject.work | \
149+
git fast-import --import-marks=../marks.git --export-marks=../marks.git
150+
----
151+
152+
Now `git branch` shows you the `master` branch as well as the `work` branch.
153+
Check the logs to make sure they’re complete and get rid of the `marks.bzr` and `marks.git` files.
154+
155+
Your Git repository is ready to use.

book/A-git-in-other-environments/sections/zsh.asc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To include the branch name in the prompt on the right side, add these lines to y
2525
[source,console]
2626
----
2727
autoload -Uz vcs_info
28-
precmd_vcs_info() { vcs_info }
28+
precmd_vcs_info() { vcs_info }
2929
precmd_functions+=( precmd_vcs_info )
3030
setopt prompt_subst
3131
RPROMPT=\$vcs_info_msg_0_

book/introduction.asc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ chapter shows you how to cope if you still have to use a SVN server. We also cov
4646
import projects from several different systems in case you do convince everyone to make the
4747
plunge.
4848

49-
*Chapter 10* delves into the murky yet beautiful depths of Git internals. Now that you know all
49+
*Chapter 10* delves into the murky yet beautiful depths of Git internals. Now that you know all
5050
about Git and can wield it with power and grace, you can move on to discuss how Git stores its objects,
5151
what the object model is, details of packfiles, server protocols, and more. Throughout the book,
52-
we will refer to sections of this chapter in case you feel like diving deep at that point;
52+
we will refer to sections of this chapter in case you feel like diving deep at that point;
5353
but if you are like us and want to dive into the technical details, you may want to read Chapter 10 first.
5454
We leave that up to you.
5555

book/preface.asc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ It's been a great pleasure and privilege to work on this book. I hope it helps y
5454

5555
_To my wife, Becky, without whom this adventure never would have begun. — Ben_
5656

57-
_This edition is dedicated to my girls.
58-
To my wife Jessica who has supported me for all of these years and to my daughter Josephine,
57+
_This edition is dedicated to my girls.
58+
To my wife Jessica who has supported me for all of these years and to my daughter Josephine,
5959
who will support me when I'm too old to know what's going on. — Scott_

0 commit comments

Comments
 (0)