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/07-git-tools/sections/subtree-merges.asc
+29-29Lines changed: 29 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,13 @@
1
1
[[_subtree_merge]]
2
2
===== Subtree Merging
3
3
4
-
The idea of the subtree merge is that you have two projects, and one of the projects maps to a subdirectory of the other one.
5
-
When you specify a subtree merge, Git is often smart enough to figure out that one is a subtree of the other and merge appropriately.
4
+
Der Grundgedanke des Teilbaum-Merge besteht darin, dass Sie zwei Projekte haben und eines der Projekte auf ein Unterverzeichnis des anderen Projekts verweist.
5
+
Wenn Sie einen Teilbaum-Merge durchführen, ist Git so versiert zu erkennen, dass das ein Unterverzeichnis ein Teilbaum des anderen ist und es entsprechend mergen.
6
6
7
-
We'll go through an example of adding a separate project into an existing project and then merging the code of the second into a subdirectory of the first.
7
+
Wir werden ein Beispiel durcharbeiten, bei dem ein separates Projekt in ein bestehendes Projekt eingefügt und dann der Code des zweiten Projekts in ein Unterverzeichnis des ersten Projekts gemergt wird.
8
8
9
-
First, we'll add the Rack application to our project.
10
-
We'll add the Rack project as a remote reference in our own project and then check it out into its own branch:
9
+
Zunächst werden wir die Anwendung „Rack“ zu unserem Projekt hinzufügen.
10
+
Wir werden das Rack-Projekt in unserem eigenen Projekt als Remote-Referenz einbinden und es dann in einem eigenen Branch auschecken:
11
11
12
12
[source,console]
13
13
----
@@ -29,8 +29,8 @@ Branch rack_branch set up to track remote branch refs/remotes/rack_remote/master
29
29
Switched to a new branch "rack_branch"
30
30
----
31
31
32
-
Now we have the root of the Rack project in our `rack_branch` branch and our own project in the `master` branch.
33
-
If you check out one and then the other, you can see that they have different project roots:
32
+
Jetzt haben wir das Root-Verzeichnis des Rack-Projekts in unserem `rack_branch` und unser eigenes Projekt im `master`-Branch.
33
+
Wenn Sie die beiden Branches prüfen, können Sie sehen, dass sie unterschiedliche Projekt-Roots haben:
34
34
35
35
[source,console]
36
36
----
@@ -43,33 +43,33 @@ $ ls
43
43
README
44
44
----
45
45
46
-
This is sort of a strange concept.
47
-
Not all the branches in your repository actually have to be branches of the same project.
48
-
It's not common, because it's rarely helpful, but it's fairly easy to have branches contain completely different histories.
46
+
Das ist ein irgendwie merkwürdiges Konzept.
47
+
Nicht alle Branches in Ihrem Repository müssen unbedingt Branches desselben Projektes sein.
48
+
Es ist nicht allgemein üblich, weil es selten hilfreich ist. Allerdings ist es ziemlich wahrscheinlich, dass die Branches völlig unterschiedliche Verläufe enthalten.
49
49
50
-
In this case, we want to pull the Rack project into our `master` project as a subdirectory.
51
-
We can do that in Git with `git read-tree`.
52
-
You'll learn more about `read-tree` and its friends in <<ch10-git-internals#ch10-git-internals>>, but for now know that it reads the root tree of one branch into your current staging area and working directory.
53
-
We just switched back to your `master` branch, and we pull the `rack_branch` branch into the `rack` subdirectory of our `master` branch of our main project:
50
+
In unserem Fall wollen wir das Rack-Projekt als Unterverzeichnis in unser Projekt `master` einbringen.
51
+
Das können wir in Git mit `git read-tree` tun.
52
+
Mehr über den Befehl `read-tree` und seiner Verwandten erfahren Sie in <<ch10-git-internals#ch10-git-internals>>. Vorab sollen Sie erfahren, dass er den Root-Tree eines Branchs in Ihre aktuelle Staging-Area und Ihr aktuelles Arbeitsverzeichnis einliest.
53
+
Wir sind gerade zu Ihrem Branch `master` zurückgewechselt und ziehen den Zweig `rack_branch` in das Unterverzeichnis `rack` unseres `master`-Branchs des Hauptprojektes:
54
54
55
55
[source,console]
56
56
----
57
57
$ git read-tree --prefix=rack/ -u rack_branch
58
58
----
59
59
60
-
When we commit, it looks like we have all the Rack files under that subdirectory – as though we copied them in from a tarball.
61
-
What gets interesting is that we can fairly easily merge changes from one of the branches to the other.
62
-
So, if the Rack project updates, we can pull in upstream changes by switching to that branch and pulling:
60
+
Bei einem Commit sieht es so aus, als befänden sich alle Rack-Dateien unterhalb dieses Unterverzeichnisses – als ob wir sie aus einem Tarball hineinkopiert hätten.
61
+
Interessant ist, dass wir Änderungen in einem der Branches relativ leicht mit anderen Branches mergen können.
62
+
Falls das Rack-Projekt aktualisiert wird, können wir die Änderungen einbinden, indem wir zu diesem Branch wechseln und pullen:
63
63
64
64
[source,console]
65
65
----
66
66
$ git checkout rack_branch
67
67
$ git pull
68
68
----
69
69
70
-
Then, we can merge those changes back into our `master` branch.
71
-
To pull in the changes and prepopulate the commit message, use the `--squash` option, as well as the recursive merge strategy's `-Xsubtree` option.
72
-
(The recursive strategy is the default here, but we include it for clarity.)
70
+
Dann können wir diese Änderungen wieder in unserem Branch `master` zusammenführen.
71
+
Um die Änderungen zu pullen und die Commit-Nachricht vorzubereiten, verwendet man die Option `--squash` sowie die Option `-Xsubtree` der rekursiven Merge-Strategie.
72
+
(Die rekursive Strategie ist hier die Voreinstellung, aber wir fügen sie der Klarheit halber ein.)
73
73
74
74
[source,console]
75
75
----
@@ -79,23 +79,23 @@ Squash commit -- not updating HEAD
79
79
Automatic merge went well; stopped before committing as requested
80
80
----
81
81
82
-
All the changes from the Rack project are merged in and ready to be committed locally.
83
-
You can also do the opposite – make changes in the `rack` subdirectory of your `master` branch and then merge them into your `rack_branch` branch later to submit them to the maintainers or push them upstream.
82
+
Alle Änderungen aus dem Rack-Projekt werden in das Projekt gemergt und können lokal committet werden.
83
+
Sie können auch das Gegenteil tun – Änderungen im Unterverzeichnis `rack` Ihres `master`-Branchss vornehmen und sie dann später in Ihren Branch `rack_branch` mergen, um sie den Autoren zu übermitteln oder sie zum Upstream zu pushen.
84
84
85
-
This gives us a way to have a workflow somewhat similar to the submodule workflow without using submodules (which we will cover in <<ch07-git-tools#_git_submodules>>).
86
-
We can keep branches with other related projects in our repository and subtree merge them into our project occasionally.
87
-
It is nice in some ways, for example all the code is committed to a single place.
88
-
However, it has other drawbacks in that it's a bit more complex and easier to make mistakes in reintegrating changes or accidentally pushing a branch into an unrelated repository.
85
+
Dadurch haben wir einen Workflow, der dem Submodul-Workflow ähnelt, ohne Submodule zu verwenden (das wir in <<ch07-git-tools#_git_submodules>> behandeln werden).
86
+
Wir können Branches mit anderen verwandten Projekten in unserem Repository vorhalten und sie gelegentlich in unserem Projekt verschmelzen.
87
+
In gewisser Weise ist das nützlich. Beispielsweise kann der gesamte Code an einen einzigen Ort übermittelt werden.
88
+
Allerdings gibt es auch Nachteile. Es ist etwas komplizierter und somit leichter, Fehler bei der Re-Integration von Änderungen zu machen oder versehentlich einen Branch in ein nicht relevantes Repository zu pushen.
89
89
90
-
Another slightly weird thing is that to get a diff between what you have in your `rack` subdirectory and the code in your `rack_branch` branch – to see if you need to merge them – you can't use the normal `diff` command.
91
-
Instead, you must run `git diff-tree` with the branch you want to compare to:
90
+
Eine weitere etwas eigenartige Eigenschaft ist, dass Sie den Unterschied zwischen dem, was in Ihrem Unterverzeichnis `rack` steht, und dem Code in Ihrem Branch `rack_branch` nicht mit dem normalen `diff`-Befehl erhalten können ( um zu prüfen, ob Sie sie mergen müssen).
91
+
Stattdessen müssen Sie `git diff-tree` auf dem Branch, mit dem Sie vergleichen wollen, ausführen:
92
92
93
93
[source,console]
94
94
----
95
95
$ git diff-tree -p rack_branch
96
96
----
97
97
98
-
Or, to compare what is in your `rack` subdirectory with what the `master` branch on the server was the last time you fetched, you can run
98
+
Um den Inhalt Ihres `rack`-Unterverzeichnisses mit dem Branch `master` auf dem Remote-Server zu vergleichen, können Sie auch folgendes ausführen:
0 commit comments