Skip to content

Commit 8d0031c

Browse files
authored
Merge pull request #83 from max123kl/Chapter_7_13
Datei replace.asc übersetzt
2 parents 8955d48 + 35dc49e commit 8d0031c

File tree

2 files changed

+45
-45
lines changed

2 files changed

+45
-45
lines changed

book/07-git-tools/sections/replace.asc

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[[_replace]]
2-
=== Replace
2+
=== Replace (Ersetzen)
33

4-
As we've emphasized before, the objects in Git's object database are unchangeable, but Git does provide an interesting way to _pretend_ to replace objects in its database with other objects.
4+
Wie wir bereits betont haben, sind die Objekte in der Objektdatenbank von Git unveränderbar, aber Git bietet eine interessante Möglichkeit, so _zu tun, als ob_ man Objekte in der Datenbank durch andere Objekte ersetzen würde.
55

6-
The `replace` command lets you specify an object in Git and say "every time you refer to _this_ object, pretend it's a _different_ object".
7-
This is most commonly useful for replacing one commit in your history with another one without having to rebuild the entire history with, say, `git filter-branch`.
6+
Der Befehl `replace` ermöglicht es Ihnen, ein Objekt in Git zu bestimmen und zu sagen „jedes Mal, wenn ich auf _dieses_ Objekt verweise, behandle es so, als wäre es ein _anderes_ Objekt“.
7+
Das wird am häufigsten gebraucht zum Ersetzen eines Commits in Ihrem Verlauf durch einen anderen, ohne dass Sie die gesamte Historie neu aufbauen müssen, wie z.B. mit `git filter-branch`.
88

9-
For example, let's say you have a huge code history and want to split your repository into one short history for new developers and one much longer and larger history for people interested in data mining.
10-
You can graft one history onto the other by "replacing" the earliest commit in the new line with the latest commit on the older one.
11-
This is nice because it means that you don't actually have to rewrite every commit in the new history, as you would normally have to do to join them together (because the parentage affects the SHA-1s).
9+
Nehmen wir zum Beispiel an, Sie haben einen riesigen Code-Verlauf und möchten Ihr Repository aufsplitten in einen kurzen Verlauf für neue Entwickler und einen viel längeren und ausführlicheren Verlauf für Leute, die sich für Data Mining interessieren.
10+
Sie können eine Historie auf eine andere aufpfropfen, indem Sie den frühesten Commit in der neuen Zeile durch den neuesten Commit in der älteren Zeile „ersetzen“.
11+
Das ist angenehm, weil es bedeutet, dass Sie nicht wirklich jeden Commit in der neuen Geschichte neu erstellen müssen, wie Sie es normalerweise tun müssten, um sie zusammenzufügen (weil die Elterngeneration die SHA-1s beeinflussen).
1212

13-
Let's try this out.
14-
Let's take an existing repository, split it into two repositories, one recent and one historical, and then we'll see how we can recombine them without modifying the recent repositories SHA-1 values via `replace`.
13+
Probieren wir das einmal aus.
14+
Nehmen wir ein vorhandenes Repository, teilen es in zwei Repositories auf, ein aktuelles und ein altes, und dann sehen wir, wie wir sie rekombinieren können, ohne die aktuellen SHA-1-Werte des Repositories durch `replace` zu verändern.
1515

16-
We'll use a simple repository with five simple commits:
16+
Wir werden ein kleines Repository mit fünf einfachen Commits verwenden:
1717

1818
[source,console]
1919
----
@@ -25,13 +25,13 @@ c6e1e95 Fourth commit
2525
c1822cf First commit
2626
----
2727

28-
We want to break this up into two lines of history.
29-
One line goes from commit one to commit four - that will be the historical one.
30-
The second line will just be commits four and five - that will be the recent history.
28+
Wir wollen dieses in zwei unterschiedliche Historien aufteilen.
29+
Eine Linie geht von „commit one“ bis „commit four“ – das wird die historische Linie sein.
30+
Die zweite Linie wird nur aus den Commits vier und fünf bestehen – das wird die jüngere Historie sein.
3131

3232
image::images/replace1.png[]
3333

34-
Well, creating the historical history is easy, we can just put a branch in the history and then push that branch to the `master` branch of a new remote repository.
34+
Nun, die Erstellung des historischen Verlaufs ist einfach, wir können einen Branch in den Verlauf einfügen und dann diesen Branch auf den `master` Branch eines neuen Remote-Repositorys pushen.
3535

3636
[source,console]
3737
----
@@ -46,7 +46,7 @@ c1822cf First commit
4646

4747
image::images/replace2.png[]
4848

49-
Now we can push the new `history` branch to the `master` branch of our new repository:
49+
Jetzt können wir den neuen Branch `history` in den `master` Branch unseres neuen Repositorys pushen:
5050

5151
[source,console]
5252
----
@@ -62,9 +62,9 @@ To [email protected]:schacon/project-history.git
6262
* [new branch] history -> master
6363
----
6464

65-
OK, so our history is published.
66-
Now the harder part is truncating our recent history down so it's smaller.
67-
We need an overlap so we can replace a commit in one with an equivalent commit in the other, so we're going to truncate this to just commits four and five (so commit four overlaps).
65+
OK, damit ist unsere Historie veröffentlicht.
66+
Nun ist der schwierigere Teil, unsere jüngste Historie nach hinten zu kürzen, damit sie kleiner wird.
67+
Wir brauchen eine Überlappung, damit wir einen Commit in der einen durch einen gleichwertigen Commit in der anderen ersetzen können. Deshalb werden wir diesen Teil auf die Commits vier und fünf kürzen (so dass sich Commit vier überlappt).
6868

6969
[source,console]
7070
----
@@ -76,12 +76,12 @@ c6e1e95 (history) Fourth commit
7676
c1822cf First commit
7777
----
7878

79-
It's useful in this case to create a base commit that has instructions on how to expand the history, so other developers know what to do if they hit the first commit in the truncated history and need more.
80-
So, what we're going to do is create an initial commit object as our base point with instructions, then rebase the remaining commits (four and five) on top of it.
79+
In diesem Fall ist es nützlich, einen Basis-Commit zu erstellen, der Anweisungen zum Erweitern der Historie enthält, damit andere Entwickler wissen, was zu tun ist, wenn sie auf den ersten Commit in der getrennten Historie treffen und mehr brauchen.
80+
Was wir also vornehmen werden, ist, ein erstes Commit-Objekt als unseren Basispunkt mit Anweisungen zu erstellen und dann die restlichen Commits (vier und fünf) darauf zu rebasieren.
8181

82-
To do that, we need to choose a point to split at, which for us is the third commit, which is `9c68fdc` in SHA-speak.
83-
So, our base commit will be based off of that tree.
84-
We can create our base commit using the `commit-tree` command, which just takes a tree and will give us a brand new, parentless commit object SHA-1 back.
82+
Dazu müssen wir einen Punkt wählen, an dem wir abspalten möchten, der in unserem Beispiel der dritte Commit ist. Er lautet `9c68fdc` in der SHA-Sprechweise.
83+
Unser Basis-Commit wird also auf diesem Baum basieren.
84+
Wir können unseren Basis-Commit mit dem Befehl `commit-tree` erstellen, der einfach einen Baum nimmt und uns ein brandneues, elternloses SHA-1 Commit-Objekt zurückgibt.
8585

8686
[source,console]
8787
----
@@ -91,16 +91,16 @@ $ echo 'Get history from blah blah blah' | git commit-tree 9c68fdc^{tree}
9191

9292
[NOTE]
9393
=====
94-
The `commit-tree` command is one of a set of commands that are commonly referred to as 'plumbing' commands.
95-
These are commands that are not generally meant to be used directly, but instead are used by *other* Git commands to do smaller jobs.
96-
On occasions when we're doing weirder things like this, they allow us to do really low-level things but are not meant for daily use.
97-
You can read more about plumbing commands in <<ch10-git-internals#_plumbing_porcelain>>
94+
Das Kommando `commit-tree` gehört zu einer Reihe von Befehlen, die allgemein als „Basis“-Befehle (engl. 'plumbing' commands) bezeichnet werden.
95+
Diese Befehle sind im Allgemeinen nicht für den direkten Einsatz gedacht, sondern werden, eingebettet in *andere* Git-Befehle, für kleinere Aufgaben verwendet.
96+
Wenn wir bei derartigen Gelegenheiten etwas Ungewöhnliches durchführen müssen, dann erlauben sie uns, echte low-level Aufgaben zu erledigen, sind aber nicht für den täglichen Gebrauch gedacht.
97+
Sie können mehr über Basisbefehle in <<ch10-git-internals#_plumbing_porcelain>> lesen.
9898
=====
9999

100100
image::images/replace3.png[]
101101

102-
OK, so now that we have a base commit, we can rebase the rest of our history on top of that with `git rebase --onto`.
103-
The `--onto` argument will be the SHA-1 we just got back from `commit-tree` and the rebase point will be the third commit (the parent of the first commit we want to keep, `9c68fdc`):
102+
OK, jetzt, wo wir einen Basis-Commit haben, können wir den Rest unseres Verlaufs mit `git rebase --onto` auf die Basis zurückführen.
103+
Das Argument `--onto` wird der SHA-1 sein, den wir gerade von `commit-tree` zurückbekommen haben und der Rebase-Punkt wird der dritte Commit sein (der Elternteil des ersten Commits, den wir behalten wollen, `9c68fdc`):
104104

105105
[source,console]
106106
----
@@ -112,11 +112,11 @@ Applying: fifth commit
112112

113113
image::images/replace4.png[]
114114

115-
OK, so now we've re-written our recent history on top of a throw away base commit that now has instructions in it on how to reconstitute the entire history if we wanted to.
116-
We can push that new history to a new project and now when people clone that repository, they will only see the most recent two commits and then a base commit with instructions.
115+
Gut, nun haben wir also unseren jüngsten Verlauf auf einer Übergabebasis neu geschrieben, die jetzt Anweisungen enthält, wie wir die gesamte Historie rekonstruieren könnten, wenn wir es wollen.
116+
Wir können diesen neuen Verlauf auf ein neues Projekt übertragen und wenn die Anwender jetzt dieses Repository klonen, sehen sie nur die beiden letzten Commits und dann einen Basis-Commit mit Instruktionen.
117117

118-
Let's now switch roles to someone cloning the project for the first time who wants the entire history.
119-
To get the history data after cloning this truncated repository, one would have to add a second remote for the historical repository and fetch:
118+
Lassen Sie uns nun die Rolle tauschen zu jemand, der das Projekt zum ersten Mal klont und den gesamten Verlauf des Projekts haben will.
119+
Um die Verlaufsdaten nach dem Klonen dieses abgetrennten Repositorys zu erhalten, müsste man einen zweiten Remote für das historische Repository hinzufügen und fetchen:
120120

121121
[source,console]
122122
----
@@ -134,7 +134,7 @@ From https://github.com/schacon/project-history
134134
* [new branch] master -> project-history/master
135135
----
136136

137-
Now the collaborator would have their recent commits in the `master` branch and the historical commits in the `project-history/master` branch.
137+
Nun würde der Mitarbeitende seine jüngsten Commits im `master` Branch und die historischen Commits im `project-history/master` Branch erhalten.
138138

139139
[source,console]
140140
----
@@ -150,15 +150,15 @@ c6e1e95 Fourth commit
150150
c1822cf First commit
151151
----
152152

153-
To combine them, you can simply call `git replace` with the commit you want to replace and then the commit you want to replace it with.
154-
So we want to replace the "fourth" commit in the `master` branch with the "fourth" commit in the `project-history/master` branch:
153+
Um sie zu vereinigen, können Sie einfach `git replace` mit dem Commit, den Sie ersetzen wollen und dann den Commit, mit dem Sie ihn ersetzen wollen, aufrufen.
154+
Wir wollen also den „vierten“ Commit im `master` Branch durch den "vierten" Commit im `project-history/master` Branch ersetzen:
155155

156156
[source,console]
157157
----
158158
$ git replace 81a708d c6e1e95
159159
----
160160

161-
Now, if you look at the history of the `master` branch, it appears to look like this:
161+
Wenn man sich nun den Verlauf des `master` Branchs anschaut, sieht er so aus:
162162

163163
[source,console]
164164
----
@@ -170,12 +170,12 @@ e146b5f Fifth commit
170170
c1822cf First commit
171171
----
172172

173-
Cool, right? Without having to change all the SHA-1s upstream, we were able to replace one commit in our history with an entirely different commit and all the normal tools (`bisect`, `blame`, etc) will work how we would expect them to.
173+
Klasse, oder? Ohne alle SHA-1s im Upstream ändern zu müssen, waren wir in der Lage, einen Commit in unserer Geschichte durch einen ganz anderen zu ersetzen, und alle normalen Werkzeuge (`bisect`, `blame`, usw.) werden so funktionieren, wie wir es erwarten dürfen.
174174

175175
image::images/replace5.png[]
176176

177-
Interestingly, it still shows `81a708d` as the SHA-1, even though it's actually using the `c6e1e95` commit data that we replaced it with.
178-
Even if you run a command like `cat-file`, it will show you the replaced data:
177+
Interessanterweise zeigt das Log immer noch `81a708d` als SHA-1, obwohl es tatsächlich die `c6e1e95` Commit-Daten verwendet, durch die wir es ersetzt haben.
178+
Selbst wenn Sie einen Befehl wie `cat-file` ausführen, zeigt er Ihnen die ersetzten Daten an:
179179

180180
[source,console]
181181
----
@@ -188,9 +188,9 @@ committer Scott Chacon <[email protected]> 1268712581 -0700
188188
fourth commit
189189
----
190190

191-
Remember that the actual parent of `81a708d` was our placeholder commit (`622e88e`), not `9c68fdce` as it states here.
191+
Vergessen Sie nicht, dass der eigentliche Elternteil von `81a708d` unser Platzhalter-Commit (`622e88e`) war, nicht `9c68fdce`, wie es hier steht.
192192

193-
Another interesting thing is that this data is kept in our references:
193+
Eine weitere wichtige Sache ist, dass diese Daten in unseren Referenzen gespeichert sind:
194194

195195
[source,console]
196196
----
@@ -202,5 +202,5 @@ e146b5f14e79d4935160c0e83fb9ebe526b8da0d commit refs/remotes/origin/master
202202
c6e1e95051d41771a649f3145423f8809d1a74d4 commit refs/replace/81a708dd0e167a3f691541c7a6463343bc457040
203203
----
204204

205-
This means that it's easy to share our replacement with others, because we can push this to our server and other people can easily download it.
206-
This is not that helpful in the history grafting scenario we've gone over here (since everyone would be downloading both histories anyhow, so why separate them?) but it can be useful in other circumstances.
205+
Das bedeutet, dass es einfach ist, unseren Ersatz mit anderen zu teilen, weil wir diesen auf unseren Server pushen können und andere Anwender ihn leicht herunterladen können.
206+
Das ist in dem Szenario zur Verlaufsoptimierung, das wir hier durchgespielt haben, nicht so hilfreich (da jeder sowieso beide Historien herunterladen würde. Warum also beide trennen?). Es kann aber unter anderen Umständen sinnvoll sein.

status.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"sections/credentials.asc": 0,
6666
"sections/debugging.asc": 100,
6767
"sections/interactive-staging.asc": 100,
68-
"sections/replace.asc": 0,
68+
"sections/replace.asc": 100,
6969
"sections/rerere.asc": 0,
7070
"sections/reset.asc": 100,
7171
"sections/revision-selection.asc": 100,

0 commit comments

Comments
 (0)