You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: book/09-git-and-other-scms/sections/client-hg.asc
+80-80Lines changed: 80 additions & 80 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,19 @@
1
-
==== Git and Mercurial
1
+
==== Git und Mercurial
2
2
3
3
(((Interoperation with other VCSs, Mercurial)))
4
4
(((Mercurial)))
5
-
The DVCS universe is larger than just Git.
6
-
In fact, there are many other systems in this space, each with their own angle on how to do distributed version control correctly.
7
-
Apart from Git, the most popular is Mercurial, and the two are very similar in many respects.
5
+
Das DVCS-Universum besteht nicht nur aus nur Git.
6
+
In diesem Bereich gibt es viele andere Systeme, jedes hat seinen eigenen Ansatz, wie eine verteilte Versionskontrolle zu funktionieren hat.
7
+
Neben Git ist Mercurial am populärsten und die beiden sind sich in vielerlei Hinsicht sehr ähnlich.
8
8
9
-
The good news, if you prefer Git's client-side behavior but are working with a project whose source code is controlled with Mercurial, is that there's a way to use Git as a client for a Mercurial-hosted repository.
10
-
Since the way Git talks to server repositories is through remotes, it should come as no surprise that this bridge is implemented as a remote helper.
11
-
The project's name is git-remote-hg, and it can be found at https://github.com/felipec/git-remote-hg[].
9
+
Die gute Nachricht, wenn Sie Gits clientseitiges Verhalten bevorzugen, aber mit einem Projekt arbeiten, dessen Quellcode mit Mercurial verwaltet wird, dann ist es möglich, Git als Client für ein von Mercurial gehostetes Repository zu verwenden.
10
+
Da die Art und Weise, wie Git über Remotes mit Server-Repositories kommuniziert, sollte es nicht überraschen, dass diese Bridge als Remote-Helfer implementiert ist.
11
+
Der Name des Projekts lautet git-remote-hg und ist unter https://github.com/felipec/git-remote-hg[] zu finden.
12
12
13
13
===== git-remote-hg
14
14
15
-
First, you need to install git-remote-hg.
16
-
This basically entails dropping its file somewhere in your path, like so:
15
+
Zuerst müssen Sie git-remote-hg installieren.
16
+
Im Wesentlichen geht es darum, die Datei irgendwo in Ihrem Pfad abzulegen, so wie hier:
Git-remote-hg has one other dependency: the `mercurial` library for Python.
27
-
If you have Python installed, this is as simple as:
25
+
…vorausgesetzt (in einer Linux-Umgebung), `~/bin` ist in Ihrem `$PATH`.
26
+
Git-remote-hg hat noch eine weitere Abhängigkeit: die `mercurial` Library für Python.
27
+
Wenn Sie Python installiert schon haben, ist das einfach:
28
28
29
29
[source,console]
30
30
----
31
31
$ pip install mercurial
32
32
----
33
33
34
-
(If you don't have Python installed, visit https://www.python.org/[] and get it first.)
34
+
(Wenn Sie Python noch nicht installiert haben, besuchen Sie https://www.python.org/[] und besorgen Sie es sich zuerst.)
35
35
36
-
The last thing you'll need is the Mercurial client.
37
-
Go to https://www.mercurial-scm.org/[] and install it if you haven't already.
36
+
Als Letztes brauchen Sie den Mercurial-Client.
37
+
Gehen Sie zu https://www.mercurial-scm.org/[] und installieren Sie ihn, falls Sie es noch nicht getan haben.
38
38
39
-
Now you're ready to rock.
40
-
All you need is a Mercurial repository you can push to.
41
-
Fortunately, every Mercurial repository can act this way, so we'll just use the "hello world" repository everyone uses to learn Mercurial:
39
+
Jetzt sind Sie bereit zu abrocken.
40
+
Alles, was Sie benötigen, ist ein Mercurial-Repository, auf das Sie zugreifen können.
41
+
Glücklicherweise kann sich jedes Mercurial-Repository so verhalten, also verwenden wir einfach das "hello world"-Repository, das jeder benutzt, um Mercurial zu lernen:
* 65bb417 Create a standard "hello, world" program
62
62
----
63
63
64
-
You'll notice that working with a Mercurial repository uses the standard `git clone` command.
65
-
That's because git-remote-hg is working at a fairly low level, using a similar mechanism to how Git's HTTP/S protocol is implemented (remote helpers).
66
-
Since Git and Mercurial are both designed for every client to have a full copy of the repository history, this command makes a full clone, including all the project's history, and does it fairly quickly.
64
+
Wie Sie sehen, verwendet man bei der Arbeit mit einem Mercurial-Repository den Standardbefehl `git clone`.
65
+
Das liegt daran, dass git-remote-hg auf einem relativ niedrigen Level arbeitet und einen ähnlichen Mechanismus verwendet, wie es die Implementierung des HTTP/S-Protokolls in Git ist (Remote-Helfer).
66
+
Da Git und Mercurial beide so konzipiert sind, dass jeder Client eine vollständige Kopie der Repository-Historie hat, erstellt dieser Befehl relativ schnell einen vollständigen Klon, einschließlich der gesamten Projekthistorie.
67
67
68
-
The log command shows two commits, the latest of which is pointed to by a whole slew of refs.
69
-
It turns out some of these aren't actually there.
70
-
Let's take a look at what's actually in the `.git` directory:
68
+
Der log-Befehl zeigt zwei Commits, von denen der letzte von einer ganzen Reihe von Refs angeführt wird.
69
+
Wie sich herausstellt, sind einige davon nicht wirklich da.
70
+
Werfen wir einen Blick darauf, was sich wirklich im `.git` Verzeichnis befindet:
71
71
72
72
[source,console]
73
73
----
@@ -91,13 +91,13 @@ $ tree .git/refs
91
91
9 directories, 5 files
92
92
----
93
93
94
-
Git-remote-hg is trying to make things more idiomatically Git-esque, but under the hood it's managing the conceptual mapping between two slightly different systems.
95
-
The `refs/hg` directory is where the actual remote refs are stored.
96
-
For example, the `refs/hg/origin/branches/default` is a Git ref file that contains the SHA-1 starting with ``ac7955c'', which is the commit that `master` points to.
97
-
So the `refs/hg` directory is kind of like a fake `refs/remotes/origin`, but it has the added distinction between bookmarks and branches.
94
+
Git-remote-hg versucht sich idiomatisch (begrifflich) an Git anzunähern, aber im Hintergrund verwaltet es die konzeptionelle Zuordnung zwischen zwei leicht unterschiedlichen Systemen.
95
+
Im Verzeichnis `refs/hg` werden die aktuellen Remote-Referenzen gespeichert.
96
+
Zum Beispiel ist die `refs/hg/origin/branches/default` eine Git ref-Datei, die das SHA-1 enthält und mit „ac7955c“ beginnt. Das ist der Commit, auf den `master` zeigt.
97
+
Das Verzeichnis `refs/hg` ist also eine Art gefälschtes `refs/remotes/origin`, aber es unterscheidet zusätzlich zwischen Lesezeichen und Zweigen.
98
98
99
-
The `notes/hg` file is the starting point for how git-remote-hg maps Git commit hashes to Mercurial changeset IDs.
100
-
Let's explore a bit:
99
+
Die Datei `notes/hg` ist der Ausgangspunkt dafür, wie git-remote-hg Git-Commit-Hashes auf Mercurial-Changeset-IDs abbildet.
100
+
Lassen Sie uns ein wenig experimentieren:
101
101
102
102
[source,console]
103
103
----
@@ -119,28 +119,28 @@ $ git cat-file -p ac9117f
119
119
0a04b987be5ae354b710cefeba0e2d9de7ad41a9
120
120
----
121
121
122
-
So `refs/notes/hg` points to a tree, which in the Git object database is a list of other objects with names.
123
-
`git ls-tree` outputs the mode, type, object hash, and filename for items inside a tree.
124
-
Once we dig down to one of the tree items, we find that inside it is a blob named ``ac9117f'' (the SHA-1 hash of the commit pointed to by `master`), with contents ``0a04b98'' (which is the ID of the Mercurial changeset at the tip of the `default` branch).
122
+
So zeigt refs/notes/hg auf einen Verzeichnisbaum, der in der Git-Objektdatenbank eine Liste anderer Objekte mit Namen ist.
123
+
`git ls-tree` gibt Modus, Typ, Objekt-Hash und Dateiname für Elemente innerhalb eines Baums aus.
124
+
Sobald wir uns auf eines der Baumelemente festgelegt haben, stellen wir fest, dass sich darin ein „ac9117f“ Blob (der SHA-1-Hash des Commit, auf den `master` zeigt) befindet. Inhaltlich ist er identisch mit "0a04b98" (das ist die ID des Mercurial-Changesets an der Spitze der `default` Branch).
125
125
126
-
The good news is that we mostly don't have to worry about all of this.
127
-
The typical workflow won't be very different from working with a Git remote.
126
+
Die gute Nachricht ist, dass wir uns darüber meistens keine Sorgen machen müssen.
127
+
Der typische Arbeitsablauf unterscheidet sich nicht wesentlich von der Arbeit mit einem Git-Remote.
128
128
129
-
There's one more thing we should attend to before we continue: ignores.
130
-
Mercurial and Git use a very similar mechanism for this, but it's likely you don't want to actually commit a `.gitignore` file into a Mercurial repository.
131
-
Fortunately, Git has a way to ignore files that's local to an on-disk repository, and the Mercurial format is compatible with Git, so you just have to copy it over:
129
+
Noch eine Besonderheit, um die wir uns kümmern sollten, bevor wir fortfahren: Die Auslassungen.
130
+
Mercurial und Git verwenden dafür einen sehr ähnlichen Mechanismus, aber es ist durchaus möglich, dass Sie eine `.gitignore` Datei nicht wirklich in ein Mercurial Repository übertragen wollen.
131
+
Glücklicherweise hat Git eine Möglichkeit, Dateien zu ignorieren, die lokal in einem On-Disk-Repository liegen. Das Mercurial-Format ist kompatibel mit Git, so dass Sie es nur kopieren müssen:
132
132
133
133
[source,console]
134
134
----
135
135
$ cp .hgignore .git/info/exclude
136
136
----
137
137
138
-
The `.git/info/exclude` file acts just like a `.gitignore`, but isn't included in commits.
138
+
Die Datei `.git/info/exclude` verhält sich wie eine `.gitignore`, wird aber nicht in den Commits aufgenommen.
139
139
140
140
===== Workflow
141
141
142
-
Let's assume we've done some work and made some commits on the `master` branch, and you're ready to push it to the remote repository.
143
-
Here's what our repository looks like right now:
142
+
Nehmen wir an, wir haben einige Arbeiten erledigt und einige Commits auf den `master` Branch gemacht und Sie sind so weit, ihn in das Remote-Repository zu pushen.
* 65bb417 Create a standard "hello, world" program
172
172
----
173
173
174
-
Since we used the `--all` flag, we see the ``notes'' refs that are used internally by git-remote-hg, but we can ignore them.
175
-
The rest is what we expected; `origin/master` has advanced by one commit, and our history has now diverged.
176
-
Unlike the other systems we work with in this chapter, Mercurial is capable of handling merges, so we're not going to do anything fancy.
174
+
Da wir das `--all` Flag verwendet haben, sehen wir die „notes“ Refs, die intern von git-remote-hg verwendet werden, die wir aber ignorieren können.
175
+
Den Rest haben wir erwartet. `origin/master` ist um einen Commit fortgeschritten. Unser Verlauf hat sich dadurch verändert.
176
+
Anders als bei anderen Systemen, mit denen wir in diesem Kapitel arbeiten, ist Mercurial in der Lage, Merges zu verarbeiten, so dass wir nichts Ausgefallenes tun müssen.
The changeset numbered _2_ was made by Mercurial, and the changesets numbered _3_ and _4_ were made by git-remote-hg, by pushing commits made with Git.
231
+
Das Change-Set mit der Nummer _2_ wurde von Mercurial vorgenommen, und die Change-Sets mit der Nummer _3_ und _4_ wurden von git-remote-hg durchgeführt, indem Commits mit Git gepusht wurden.
232
232
233
-
===== Branches and Bookmarks
233
+
===== Branches und Bookmarks
234
234
235
-
Git has only one kind of branch: a reference that moves when commits are made.
236
-
In Mercurial, this kind of a reference is called a ``bookmark,'' and it behaves in much the same way as a Git branch.
235
+
Git hat nur eine Art von Branch: eine Referenz, die sich verschiebt, wenn Commits gemacht werden.
236
+
In Mercurial wird diese Art von Referenz als „bookmark“ (dt. Lesezeichen) bezeichnet, und sie verhält sich ähnlich wie ein Git-Branch.
237
237
238
-
Mercurial's concept of a ``branch'' is more heavyweight.
239
-
The branch that a changeset is made on is recorded _with the changeset_, which means it will always be in the repository history.
240
-
Here's an example of a commit that was made on the `develop` branch:
238
+
Das Konzept von Mercurial eines „Branchs“ ist höher gewichtet.
239
+
Der Branch, auf den ein Changeset durchgeführt wird, wird _zusammen mit dem Changeset_ aufgezeichnet, d.h. er befindet sich immer im Repository-Verlauf.
240
+
Hier ist ein Beispiel für einen Commit, der auf dem `develop` Branch gemacht wurde:
Git can't really replicate this (and doesn't need to; both types of branch can be represented as a Git ref), but git-remote-hg needs to understand the difference, because Mercurial cares.
253
+
Achten Sie darauf, dass die Zeile mit „branch“ beginnt.
254
+
Git kann das nicht wirklich nachahmen (und muss es auch nicht; beide Arten von Zweigen können als Git ref dargestellt werden), aber git-remote-hg muss den Unterschied erkennen, denn für Mercurial ist er wichtig.
255
255
256
-
Creating Mercurial bookmarks is as easy as creating Git branches.
257
-
On the Git side:
256
+
Das Anlegen von Mercurial-Lesezeichen ist so einfach wie das Erstellen von Git-Branches.
257
+
Auf der Seite vom Git machen Sie:
258
258
259
259
[source,console]
260
260
----
@@ -265,8 +265,8 @@ To hg::/tmp/hello
265
265
* [new branch] featureA -> featureA
266
266
----
267
267
268
-
That's all there is to it.
269
-
On the Mercurial side, it looks like this:
268
+
Das ist alles, was es dazu zu sagen gibt.
269
+
Auf der Mercurial-Seite sieht es dann folgendermaßen aus:
These act exactly like Git branches on the Git side, with one exception: you can't delete a bookmark from the Git side (this is a limitation of remote helpers).
298
+
Beachten Sie den neuen `[featureA]` Tag auf Revision 5.
299
+
Die verhalten sich genau wie Git-Branches auf der Git-Seite, mit einer Ausnahme: Sie können ein Lesezeichen auf der Git-Seite nicht löschen (das ist eine Einschränkung des Remote-Helfers).
300
300
301
-
You can work on a ``heavyweight'' Mercurial branch also: just put a branch in the `branches` namespace:
301
+
Sie können auch an einem „schwergewichtigen“ Mercurial-Branch arbeiten: Bringen Sie einfach einen Branch in den `branches` Namensraum:
Here's what that looks like on the Mercurial side:
314
+
So sieht das dann auf der Mercurial-Seite aus:
315
315
316
316
[source,console]
317
317
----
@@ -344,11 +344,11 @@ o changeset: 5:bd5ac26f11f9
344
344
[...]
345
345
----
346
346
347
-
The branch name ``permanent'' was recorded with the changeset marked _7_.
347
+
Der Branch-Name „permanent“ wurde mit dem Change-Set _7_ eingetragen.
348
348
349
-
From the Git side, working with either of these branch styles is the same: just checkout, commit, fetch, merge, pull, and push as you normally would.
350
-
One thing you should know is that Mercurial doesn't support rewriting history, only adding to it.
351
-
Here's what our Mercurial repository looks like after an interactive rebase and a force-push:
349
+
Seitens von Git ist die Arbeit mit einem dieser Branch-Stile die gleiche: Einfach auschecken, committen, fetchen, mergen, pullen, und pushen, wie Sie es üblicherweise machen würden.
350
+
Eine Sache, die Sie wissen sollten, ist, dass Mercurial das Überschreiben der Historie nicht unterstützt, sondern nur hinzufügt.
351
+
Das Mercurial-Repository sieht nach einem interaktiven Rebase und einem Force-Push so aus:
Changesets _8_, _9_, and _10_ have been created and belong to the `permanent` branch, but the old changesets are still there.
391
-
This can be *very* confusing for your teammates who are using Mercurial, so try to avoid it.
390
+
Die Changesets _8_, _9_ und _10_ wurden angelegt und gehören zum `permanent` Branch, aber die alten Changesets sind immer noch vorhanden.
391
+
Das kann für Ihre Teamkollegen, die Mercurial verwenden, *sehr verwirrend* sein, also versuchen Sie es zu vermeiden.
392
392
393
393
394
-
===== Mercurial Summary
394
+
===== Mercurial Zusammenfassung
395
395
396
-
Git and Mercurial are similar enough that working across the boundary is fairly painless.
397
-
If you avoid changing history that's left your machine (as is generally recommended), you may not even be aware that the other end is Mercurial.
396
+
Git und Mercurial sind sich ähnlich genug, um über die eigene Umgebung hinaus schmerzlos zu arbeiten.
397
+
Wenn Sie vermeiden, den Verlauf zu ändern, der Ihren Computer verlässt (was allgemein empfohlen wird), merken Sie wahrscheinlich nicht einmal, dass am anderen Ende Mercurial verwendet wird.
0 commit comments