From cbef4c38872ca47233c82f2909486f6cd063a277 Mon Sep 17 00:00:00 2001 From: Dieter Ziller Date: Tue, 7 Jan 2020 15:02:31 +0100 Subject: [PATCH 1/3] Update rewriting-history.asc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit aus engl. Repo übernommen --- book/07-git-tools/sections/rewriting-history.asc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/book/07-git-tools/sections/rewriting-history.asc b/book/07-git-tools/sections/rewriting-history.asc index 86bcbb10..8d1f38eb 100644 --- a/book/07-git-tools/sections/rewriting-history.asc +++ b/book/07-git-tools/sections/rewriting-history.asc @@ -304,6 +304,13 @@ The command is `filter-branch`, and it can rewrite huge swaths of your history, However, it can be very useful. You'll learn a few of the common uses so you can get an idea of some of the things it's capable of. +[CAUTION] +==== +`git filter-branch` has many pitfalls, and is no longer the recommended way to rewrite history. +Instead, consider using `git-filter-repo`, which is a Python script that does a better job for most applications where you would normally turn to `filter-branch`. +Its documentation and source code can be found at https://github.com/newren/git-filter-repo[]. +==== + [[_removing_file_every_commit]] ===== Removing a File from Every Commit From 051ea9cffc76c0d68af6633b0b5c81e7d157aaaf Mon Sep 17 00:00:00 2001 From: Dieter Ziller Date: Wed, 8 Jan 2020 19:09:50 +0100 Subject: [PATCH 2/3] Update rewriting-history.asc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Datei übersetzt --- .../sections/rewriting-history.asc | 212 +++++++++--------- 1 file changed, 106 insertions(+), 106 deletions(-) diff --git a/book/07-git-tools/sections/rewriting-history.asc b/book/07-git-tools/sections/rewriting-history.asc index 8d1f38eb..a7f0140c 100644 --- a/book/07-git-tools/sections/rewriting-history.asc +++ b/book/07-git-tools/sections/rewriting-history.asc @@ -1,49 +1,49 @@ [[_rewriting_history]] -=== Rewriting History +=== Den Verlauf umschreiben -Many times, when working with Git, you may want to revise your local commit history. -One of the great things about Git is that it allows you to make decisions at the last possible moment. -You can decide what files go into which commits right before you commit with the staging area, you can decide that you didn't mean to be working on something yet with `git stash`, and you can rewrite commits that already happened so they look like they happened in a different way. -This can involve changing the order of the commits, changing messages or modifying files in a commit, squashing together or splitting apart commits, or removing commits entirely -- all before you share your work with others. +Bei der Arbeit mit Git möchten Sie vielleicht manchmal Ihren lokalen Commit-Verlauf überarbeiten. +Eine der genialen Eigenschaften von Git ist, dass es einem ermöglicht, Entscheidungen im letztmöglichen Moment zu treffen. +Sie können bestimmen, welche Dateien in welche Commits gehen, kurz bevor Sie mit der Staging-Area committen. Sie können mit `git stash` festlegen, dass Sie jetzt noch nicht an etwas arbeiten wollen und Sie können Commits, die bereits durchgeführt wurden, so umschreiben, dass es so aussieht, als wären sie auf eine ganz andere Art und Weise erfolgt. +Das kann eine Änderung der Reihenfolge der Commits umfassen, das Ändern von Nachrichten oder das Modifizieren von Dateien in einem Commit, das Zusammenfügen oder Aufteilen von Commits, oder das komplette Entfernen von Commits – alles bevor Sie Ihre Arbeit mit anderen teilen. -In this section, you'll see how to accomplish these tasks so that you can make your commit history look the way you want before you share it with others. +In diesem Abschnitt zeigen wir, wie Sie diese Aufgaben erledigen können, damit Sie Ihre Commit-Historie so aussehen lassen können, wie Sie es wünschen, bevor Sie sie mit anderen teilen. [NOTE] -.Don't push your work until you're happy with it +.Sie sollten Ihre Arbeit nicht pushen, solange Sie damit nicht zufrieden sind. ==== -One of the cardinal rules of Git is that, since so much work is local within your clone, you have a great deal of freedom to rewrite your history _locally_. -However, once you push your work, it is a different story entirely, and you should consider pushed work as final unless you have good reason to change it. -In short, you should avoid pushing your work until you're happy with it and ready to share it with the rest of the world. +Eine der wichtigsten Eigenschaften von Git ist die Möglichkeit die Verlaufshistorie, _innerhalb Ihres lokalen Klons_, nach Ihren Wünschen umzuschreiben, weil der größte Teil der Arbeit vor Ort geschieht. +Wenn Sie Ihre Arbeit jedoch einmal gepusht haben, ist das eine ganz andere Geschichte und Sie sollten die gepushte Arbeit als endgültig betrachten – es sei denn, Sie haben gute Gründe, diese zu ändern. +Um es kurz zu machen: Vermeiden Sie es, Ihre Arbeit so lange zu pushen, bis Sie mit ihr zufrieden sind und bereit sind, sie mit dem Rest der Welt zu teilen. ==== [[_git_amend]] -==== Changing the Last Commit +==== Den letzten Commit ändern -Changing your most recent commit is probably the most common rewriting of history that you'll do. -You'll often want to do two basic things to your last commit: simply change the commit message, or change the actual content of the commit by adding, removing and modifying files. +Das Ändern des letzten Commits ist vermutlich der häufigste Grund für die Neufassung der Versionsgeschichte. +Sie werden oft zwei wesentliche Änderungen an Ihrem letzten Commit vornehmen wollen: einfach die Commit-Beschreibung ändern oder den eigentlichen Inhalt des Commits ändern, indem Sie Dateien hinzufügen, entfernen oder modifizieren. -If you simply want to modify your last commit message, that's easy: +Wenn Sie lediglich die letzte Commit-Beschreibung ändern wollen, ist das einfach: [source,console] ---- $ git commit --amend ---- -The command above loads the previous commit message into an editor session, where you can make changes to the message, save those changes and exit. -When you save and close the editor, the editor writes a new commit containing that updated commit message and makes it your new last commit. +Der obige Befehl lädt die vorherige Commit-Beschreibung in eine Editorsitzung, in der Sie Änderungen an der Meldung vornehmen, diese Änderungen speichern und die Sitzung beenden können. +Wenn Sie die Nachricht speichern und schließen, schreibt der Editor einen neuen Commit, der diese aktualisierte Commit-Beschreibung enthält, und macht ihn zu Ihrer neuen letzten Commit-Beschreibung. -If, on the other hand, you want to change the actual _content_ of your last commit, the process works basically the same way -- first make the changes you think you forgot, stage those changes, and the subsequent `git commit --amend` _replaces_ that last commit with your new, improved commit. +Wenn Sie andererseits den eigentlichen _Inhalt_ Ihrer letzten Übertragung ändern wollen, funktioniert der Prozess im Prinzip auf die gleiche Weise – machen Sie zuerst die Änderungen, die Sie glauben, vergessen zu haben, stagen Sie diese Änderungen und der anschließende `git commit --amend` _ersetzt_ diesen letzten Commit durch Ihren neuen, verbesserten Commit. -You need to be careful with this technique because amending changes the SHA-1 of the commit. -It's like a very small rebase -- don't amend your last commit if you've already pushed it. +Sie müssen mit dieser Technik vorsichtig sein, da die Änderung den SHA-1 des Commits ändert. +Es ist wie ein sehr kleiner Rebase – ändern Sie Ihren letzten Commit nicht, wenn Sie ihn bereits gepusht haben. [TIP] -.An amended commit may (or may not) need an amended commit message +.Ein geänderter Commit kann (eventuell) eine geänderte Commit-Beschreibung benötigen ==== -When you amend a commit, you have the opportunity to change both the commit message and the content of the commit. -If you amend the content of the commit substantially, you should almost certainly update the commit message to reflect that amended content. +Wenn Sie einen Commit ändern, haben Sie die Möglichkeit, sowohl die Commit-Beschreibung als auch den Inhalt des Commits zu ändern. +Wenn Sie den Inhalt des Commits maßgeblich ändern, sollten Sie die Commit-Beschreibung mit Bestimmtheit aktualisieren, um den geänderten Inhalt widerzuspiegeln. -On the other hand, if your amendments are suitably trivial (fixing a silly typo or adding a file you forgot to stage) such that the earlier commit message is just fine, you can simply make the changes, stage them, and avoid the unnecessary editor session entirely with: +Wenn Ihre Änderungen andererseits trivial sind (ein dummer Tippfehler wurde korrigiert oder eine Datei hinzugefügt, die Sie vergessen haben zu stagen) und die frühere Commit-Beschreibung ist in Ordnung, dann können Sie einfach die Änderungen vornehmen, sie stagen und die unnötige Editorsitzung vermeiden: [source,console] ---- @@ -53,26 +53,26 @@ $ git commit --amend --no-edit ==== [[_changing_multiple]] -==== Changing Multiple Commit Messages +==== Ändern mehrerer Commit-Beschreibungen -To modify a commit that is farther back in your history, you must move to more complex tools. -Git doesn't have a modify-history tool, but you can use the rebase tool to rebase a series of commits onto the HEAD they were originally based on instead of moving them to another one. -With the interactive rebase tool, you can then stop after each commit you want to modify and change the message, add files, or do whatever you wish. -You can run rebase interactively by adding the `-i` option to `git rebase`. -You must indicate how far back you want to rewrite commits by telling the command which commit to rebase onto. +Um einen Commit zu ändern, der weiter zurückliegt, müssen Sie zu komplexeren Werkzeugen wechseln. +Git hat kein Tool zum Ändern der Historie, aber Sie können das Rebase-Werkzeug verwenden, um eine Reihe von Commits auf den HEAD zu übertragen, auf dem sie ursprünglich basieren, anstatt sie auf einen anderen zu verschieben. +Mit dem interaktiven Rebase-Werkzeug können Sie dann nach jedem Commit pausieren und die Beschreibung ändern, Dateien hinzufügen oder was immer Sie wollen. +Sie können Rebase interaktiv ausführen, indem Sie die Option `-i` mit `git rebase` verwenden. +Sie müssen angeben, wie weit Sie die Commits umschreiben wollen, indem Sie dem Kommando den Commit nennen, auf den Sie umbasen wollen. -For example, if you want to change the last three commit messages, or any of the commit messages in that group, you supply as an argument to `git rebase -i` the parent of the last commit you want to edit, which is `HEAD~2^` or `HEAD~3`. -It may be easier to remember the `~3` because you're trying to edit the last three commits, but keep in mind that you're actually designating four commits ago, the parent of the last commit you want to edit: +Wenn Sie zum Beispiel die letzten drei Commit-Beschreibungen oder eine der Commit-Beschreibungen in dieser Gruppe ändern wollen, geben Sie als Argument für `git rebase -i` das Elternteil der letzten Commit-Beschreibung, die Sie bearbeiten wollen, an (`HEAD~2^` oder `HEAD~3`). +Es ist vielleicht einfacher, sich die `~3` zu merken, weil Sie versuchen, die letzten drei Commits zu bearbeiten. Bedenken Sie aber, dass Sie eigentlich vier Commits angeben müssen, den Elternteil des letzten Commits, den Sie bearbeiten wollen: [source,console] ---- $ git rebase -i HEAD~3 ---- -Remember again that this is a rebasing command -- every commit in the range `HEAD~3..HEAD` with a changed message _and all of its descendants_ will be rewritten. -Don't include any commit you've already pushed to a central server -- doing so will confuse other developers by providing an alternate version of the same change. +Bitte vergessen Sie nicht, dass es sich hierbei um einen Rebasing-Befehl handelt – jeder Commit im Bereich `HEAD~3..HEAD` mit einer geänderten Beschreibung und _allen seinen Nachfolgern_ wird neu geschrieben. +Fügen Sie keinen Commit ein, den Sie bereits auf einen zentralen Server gepusht haben – das wird andere Entwickler verwirren, weil sie eine neue Version der gleichen Änderung übermitteln. -Running this command gives you a list of commits in your text editor that looks something like this: +Wenn Sie diesen Befehl ausführen, erhalten Sie eine Liste von Commits in Ihrem Texteditor, die ungefähr so aussieht: [source,console] ---- @@ -107,8 +107,8 @@ pick a5f4a0d added cat-file # Note that empty commits are commented out ---- -It's important to note that these commits are listed in the opposite order than you normally see them using the `log` command. -If you run a `log`, you see something like this: +Es ist wichtig zu erwähnen, dass diese Commits in der umgekehrten Reihenfolge aufgelistet werden, als Sie sie normalerweise mit dem `log` Befehl sehen. +Wenn Sie ein `log` ausführen, sehen Sie etwas wie das hier: [source,console] ---- @@ -118,14 +118,14 @@ a5f4a0d added cat-file f7f3f6d changed my name a bit ---- -Notice the reverse order. -The interactive rebase gives you a script that it's going to run. -It will start at the commit you specify on the command line (`HEAD~3`) and replay the changes introduced in each of these commits from top to bottom. -It lists the oldest at the top, rather than the newest, because that's the first one it will replay. +Beachten Sie die entgegengesetzte Reihenfolge. +Das interaktive Rebase stellt Ihnen ein Skript zur Verfügung, das es ausführen wird. +Es beginnt mit dem Commit, den Sie auf der Kommandozeile angeben (`HEAD~3`) und gibt die Änderungen, die in jedem dieser Commits eingeführt wurden, von oben nach unten wieder. +Es listet die ältesten oben auf, nicht die neuesten, weil es die ersten sind, die es wiedergibt. -You need to edit the script so that it stops at the commit you want to edit. -To do so, change the word `pick' to the word `edit' for each of the commits you want the script to stop after. -For example, to modify only the third commit message, you change the file to look like this: +Sie müssen das Skript so bearbeiten, dass es bei dem Commit anhält, den Sie bearbeiten wollen. +Ändern Sie dazu das Wort ‚pick‘ in das Wort ‚edit‘ für jeden Commit, nach dem das Skript anhalten soll. +Um beispielsweise nur die dritte Commit-Beschreibung zu ändern, ändern Sie die Datei so, dass sie wie folgt aussieht: [source,console] ---- @@ -134,7 +134,7 @@ pick 310154e updated README formatting and added blame pick a5f4a0d added cat-file ---- -When you save and exit the editor, Git rewinds you back to the last commit in that list and drops you on the command line with the following message: +Wenn Sie speichern und den Editor verlassen, springt Git zum letzten Commit in dieser Liste zurück und zeigt Ihnen die folgende Meldung an der Kommandozeile an: [source,console] ---- @@ -149,30 +149,30 @@ Once you're satisfied with your changes, run git rebase --continue ---- -These instructions tell you exactly what to do. -Type +Diese Hinweise sagen Ihnen genau, was zu tun ist. +Schreiben Sie [source,console] ---- $ git commit --amend ---- -Change the commit message, and exit the editor. -Then, run +Ändern Sie die Commit-Beschreibung und verlassen Sie den Editor. +Dann rufen Sie folgenden Befehl auf: [source,console] ---- $ git rebase --continue ---- -This command will apply the other two commits automatically, and then you're done. -If you change pick to edit on more lines, you can repeat these steps for each commit you change to edit. -Each time, Git will stop, let you amend the commit, and continue when you're finished. +Damit setzen Sie die anderen beiden Commits automatisch fort und Sie sind fertig. +Falls Sie „pick“ zum Bearbeiten in mehreren Zeilen zu „edit“ ändern, können Sie diese Schritte für jede zu bearbeitenden Commit wiederholen. +Jedes Mal hält Git an, lässt Sie den Commit ändern und fährt fort, sobald Sie fertig sind. -==== Reordering Commits +==== Commits umsortieren -You can also use interactive rebases to reorder or remove commits entirely. -If you want to remove the ``added cat-file'' commit and change the order in which the other two commits are introduced, you can change the rebase script from this +Sie können interaktive Rebases auch verwenden, um Commits neu anzuordnen oder ganz zu entfernen. +Wenn Sie unten den „added cat-file“ Commit entfernen und die Reihenfolge ändern wollen, in der die anderen beiden Commits aufgeführt werden, können Sie das Rebase-Skript so anpassen (vorher): [source,console] ---- @@ -181,7 +181,7 @@ pick 310154e updated README formatting and added blame pick a5f4a0d added cat-file ---- -to this: +nachher: [source,console] ---- @@ -189,14 +189,14 @@ pick 310154e updated README formatting and added blame pick f7f3f6d changed my name a bit ---- -When you save and exit the editor, Git rewinds your branch to the parent of these commits, applies `310154e` and then `f7f3f6d`, and then stops. -You effectively change the order of those commits and remove the ``added cat-file'' commit completely. +Wenn Sie gespeichert und den Editor verlassen haben, blättert Git Ihren Branch zum Elternteil dieser Commits zurück, wendet `310154e` und dann `f7f3f6d` an und stoppt dann. +Sie ändern effektiv die Reihenfolge dieser Commits und entfernen den „added cat-file“ Commit komplett. [[_squashing]] -==== Squashing Commits +==== Commits zusammenfassen -It's also possible to take a series of commits and squash them down into a single commit with the interactive rebasing tool. -The script puts helpful instructions in the rebase message: +Es ist auch möglich, eine Reihe von Commits zu erfassen und sie mit dem interaktiven Rebasing-Werkzeug zu einem einzigen Commit zusammenzufassen. +Das Skript fügt hilfreiche Anweisungen in die Rebasemeldung ein: [source,console] ---- @@ -226,8 +226,8 @@ The script puts helpful instructions in the rebase message: # Note that empty commits are commented out ---- -If, instead of ``pick'' or ``edit'', you specify ``squash'', Git applies both that change and the change directly before it and makes you merge the commit messages together. -So, if you want to make a single commit from these three commits, you make the script look like this: +Wenn Sie statt „pick“ oder „edit“ „squash“ angeben, wendet Git sowohl diese Änderung als auch die Änderung direkt davor an und lässt Sie die Commit-Beschreibungen zusammenfügen. +Wenn Sie also einen einzelnen Commit aus diesen drei Commits machen wollen, müssen Sie das Skript wie folgt anpassen: [source,console] ---- @@ -236,7 +236,7 @@ squash 310154e updated README formatting and added blame squash a5f4a0d added cat-file ---- -When you save and exit the editor, Git applies all three changes and then puts you back into the editor to merge the three commit messages: +Wenn Sie speichern und den Editor schließen, wendet Git alle drei Änderungen an und öffnet dann wieder den Editor, um die drei Commit-Beschreibungen zusammenzuführen: [source,console] ---- @@ -253,14 +253,14 @@ updated README formatting and added blame added cat-file ---- -When you save that, you have a single commit that introduces the changes of all three previous commits. +Wenn Sie das speichern, haben Sie einen einzigen Commit, der die Änderungen aller drei vorherigen Commits einbringt. -==== Splitting a Commit +==== Aufspalten eines Commits -Splitting a commit undoes a commit and then partially stages and commits as many times as commits you want to end up with. -For example, suppose you want to split the middle commit of your three commits. -Instead of ``updated README formatting and added blame'', you want to split it into two commits: ``updated README formatting'' for the first, and ``added blame'' for the second. -You can do that in the `rebase -i` script by changing the instruction on the commit you want to split to ``edit'': +Das Aufteilen eines Commits macht einen Commit rückgängig und stagt dann partiell so viele Commits, wie Sie am Ende haben wollen. +Nehmen wir beispielsweise an, Sie wollten den mittleren Commit Ihrer drei Commits teilen. +Statt „updated README formatting and added blame“ wollen Sie ihn in zwei Commits aufteilen: „updated README formatting“ für die erste und „added blame“ für die zweite. +Sie können das mit dem `rebase -i` Skript tun, indem Sie die Anweisung für den Commit, den Sie aufteilen wollen, in „edit“ ändern: [source,console] ---- @@ -269,10 +269,10 @@ edit 310154e updated README formatting and added blame pick a5f4a0d added cat-file ---- -Then, when the script drops you to the command line, you reset that commit, take the changes that have been reset, and create multiple commits out of them. -When you save and exit the editor, Git rewinds to the parent of the first commit in your list, applies the first commit (`f7f3f6d`), applies the second (`310154e`), and drops you to the console. -There, you can do a mixed reset of that commit with `git reset HEAD^`, which effectively undoes that commit and leaves the modified files unstaged. -Now you can stage and commit files until you have several commits, and run `git rebase --continue` when you're done: +Wenn das Skript Sie dann auf die Befehlszeile zurückführt, setzen Sie diesen Commit zurück, übernehmen die zurückgesetzten Änderungen und erstellen daraus mehrere Commits. +Wenn Sie speichern und den Editor verlassen, springt Git zum Elternteil des ersten Commits in Ihrer Liste zurück, wendet den ersten Commit an (`f7f3f6d`), wendet den zweiten an (`310154e`) und lässt Sie auf der Konsole stehen. +Dort können Sie ein kombiniertes Zurücksetzen dieses Commits mit `git reset HEAD^` durchführen, was praktisch den Commit rückgängig macht und die modifizierten Dateien unberührt (engl. unstaged) lässt. +Jetzt können Sie Dateien so lange stagen und committen, bis Sie mehrere Commits ausgeführt haben, und danach, wenn Sie fertig sind, `git rebase --continue` starten: [source,console] ---- @@ -284,7 +284,7 @@ $ git commit -m 'added blame' $ git rebase --continue ---- -Git applies the last commit (`a5f4a0d`) in the script, and your history looks like this: +Git wendet den letzten Commit (`a5f4a0d`) im Skript an, und Ihr Verlauf sieht dann so aus: [source,console] ---- @@ -295,30 +295,30 @@ $ git log -4 --pretty=format:"%h %s" f3cc40e changed my name a bit ---- -Once again, this changes the SHA-1s of all the commits in your list, so make sure no commit shows up in that list that you've already pushed to a shared repository. +Zur Erinnerung, das ändert die SHA-1s *aller* Commits in Ihrer Liste, also stellen Sie sicher, dass *kein* Commit in dieser Liste auftaucht, den Sie bereits in ein gemeinsames Repository gepusht haben. -==== The Nuclear Option: filter-branch +==== Die Nuklear-Option: filter-branch -There is another history-rewriting option that you can use if you need to rewrite a larger number of commits in some scriptable way -- for instance, changing your email address globally or removing a file from every commit. -The command is `filter-branch`, and it can rewrite huge swaths of your history, so you probably shouldn't use it unless your project isn't yet public and other people haven't based work off the commits you're about to rewrite. -However, it can be very useful. -You'll learn a few of the common uses so you can get an idea of some of the things it's capable of. +Es gibt noch eine weitere Option zum Überschreiben der Historie, wenn Sie eine größere Anzahl von Commits auf eine skriptfähige Art und Weise umschreiben müssen – wenn Sie, zum Beispiel, Ihre E-Mail-Adresse global ändern oder eine Datei aus jedem Commit entfernen wollen. +Der Befehl heißt `filter-branch` und kann große Teile Ihres Verlaufs neu schreiben. Sie sollten ihn deshalb besser nicht verwenden. Es sei denn, Ihr Projekt ist noch nicht veröffentlicht und andere Leute haben noch keine Arbeiten an den Commits durchgeführt, die Sie gerade neu schreiben wollen. +Wie auch immer, er kann sehr nützlich sein. +Sie werden ein paar der häufigsten Verwendungszwecke kennen lernen, damit Sie eine Vorstellung gewinnen können, wofür er geeignet ist. [CAUTION] ==== -`git filter-branch` has many pitfalls, and is no longer the recommended way to rewrite history. -Instead, consider using `git-filter-repo`, which is a Python script that does a better job for most applications where you would normally turn to `filter-branch`. -Its documentation and source code can be found at https://github.com/newren/git-filter-repo[]. +`git filter-branch` hat viele Fallstricke und wird nicht mehr empfohlen, um die Chronik umzuschreiben. +Stattdessen sollten Sie die Verwendung von `git-filter-repo` in Betracht ziehen. Das ist ein Python-Skript, das für die meisten Aufgaben besser geeignet ist, bei denen Sie normalerweise auf `filter-branch` zurückgreifen würden. +Die zugehörige Dokumentation und den Quellcode finden Sie unter https://github.com/newren/git-filter-repo[]. ==== [[_removing_file_every_commit]] -===== Removing a File from Every Commit +===== Eine Datei aus *jedem* Commit entfernen -This occurs fairly commonly. -Someone accidentally commits a huge binary file with a thoughtless `git add .`, and you want to remove it everywhere. -Perhaps you accidentally committed a file that contained a password, and you want to make your project open source. -`filter-branch` is the tool you probably want to use to scrub your entire history. -To remove a file named `passwords.txt` from your entire history, you can use the `--tree-filter` option to `filter-branch`: +Das kommt relativ häufig vor. +Jemand übergibt versehentlich eine riesige Binärdatei mit einem gedankenlosen `git add .` und Sie wollen sie überall entfernen. +Vielleicht haben Sie versehentlich eine Datei übergeben, die ein Passwort enthält und Sie wollen Ihr Projekt zu Open Source machen. +`filter-branch` ist das Mittel der Wahl, um Ihren gesamten Verlauf zu säubern. +Um eine Datei namens `passwords.txt` aus Ihrem gesamten Verlauf zu entfernen, können Sie die Option `--tree-filter` mit `filter-branch` verwenden: [source,console] ---- @@ -327,18 +327,18 @@ Rewrite 6b9b3cf04e7c5686a9cb838c3f36a8cb6a0fc2bd (21/21) Ref 'refs/heads/master' was rewritten ---- -The `--tree-filter` option runs the specified command after each checkout of the project and then recommits the results. -In this case, you remove a file called `passwords.txt` from every snapshot, whether it exists or not. -If you want to remove all accidentally committed editor backup files, you can run something like `git filter-branch --tree-filter 'rm -f *~' HEAD`. +Die Option `--tree-filter` führt den angegebenen Befehl nach jedem Checkout des Projekts aus und überträgt die Ergebnisse erneut. +In diesem Fall entfernen Sie die Datei `passwords.txt` aus jedem Schnappschuss, unabhängig davon, ob sie existiert oder nicht. +Wenn Sie alle versehentlich übertragenen Editor-Backup-Dateien entfernen möchten, können Sie beispielsweise `git filter-branch --tree-filter 'rm -f *~' HEAD` ausführen. -You'll be able to watch Git rewriting trees and commits and then move the branch pointer at the end. -It's generally a good idea to do this in a testing branch and then hard-reset your master branch after you've determined the outcome is what you really want. -To run `filter-branch` on all your branches, you can pass `--all` to the command. +Sie werden in der Lage sein, Git beim Umschreiben der Bäume und Commits zu beobachten und am Ende den Branch-Pointer zu bewegen. +Generell ist es ratsam, das in einem Test-Branch zu tun und den Master-Zweig hart zurückzusetzen, wenn das Ergebnis so ist, wie Sie es erwartet haben. +Um `filter-branch` auf allen Ihren Branches auszuführen, können Sie die Option `--all` an den Befehl übergeben. -===== Making a Subdirectory the New Root +===== Ein Unterverzeichnis zur neuen Root machen -Suppose you've done an import from another source control system and have subdirectories that make no sense (`trunk`, `tags`, and so on). -If you want to make the `trunk` subdirectory be the new project root for every commit, `filter-branch` can help you do that, too: +Nehmen wir an, Sie haben einen Import aus einem anderen Versionsverwaltungssystem durchgeführt und verfügen über Unterverzeichnisse, die keinen Sinn machen (`trunk`, `tags` usw.). +Wenn Sie das `trunk` Unterverzeichnis zum neuen Stamm-Verzeichnis des Projekts für jeden Commit machen wollen, kann Ihnen `filter-branch` auch dabei helfen: [source,console] ---- @@ -347,14 +347,14 @@ Rewrite 856f0bf61e41a27326cdae8f09fe708d679f596f (12/12) Ref 'refs/heads/master' was rewritten ---- -Now your new project root is what was in the `trunk` subdirectory each time. -Git will also automatically remove commits that did not affect the subdirectory. +Jetzt ist Ihr neues Projekt-Stammverzeichnis das, was sich vorher im Unterverzeichnis `trunk` befand. +Git wird automatisch Commits entfernen, die sich nicht auf das Unterverzeichnis auswirken. -===== Changing Email Addresses Globally +===== Globales Ändern von E-Mail-Adressen -Another common case is that you forgot to run `git config` to set your name and email address before you started working, or perhaps you want to open-source a project at work and change all your work email addresses to your personal address. -In any case, you can change email addresses in multiple commits in a batch with `filter-branch` as well. -You need to be careful to change only the email addresses that are yours, so you use `--commit-filter`: +Ein weiterer häufiger Fall ist, dass Sie vergessen haben, `git config` auszuführen, um Ihren Namen und Ihre E-Mail-Adresse vor Beginn der Arbeit festzulegen oder vielleicht wollen Sie ein Open-Source-Projekt eröffnen und alle Ihre Arbeits-E-Mail-Adressen auf Ihre persönliche Adresse ändern. +In jedem Fall können Sie die E-Mail-Adressen in mehreren Commits in einem Batch mit `filter-branch` ebenfalls ändern. +Sie müssen darauf achten, nur die E-Mail-Adressen zu ändern, die Ihnen gehören, deshalb sollten Sie `--commit-filter` verwenden: [source,console] ---- @@ -369,5 +369,5 @@ $ git filter-branch --commit-filter ' fi' HEAD ---- -This goes through and rewrites every commit to have your new address. -Because commits contain the SHA-1 values of their parents, this command changes every commit SHA-1 in your history, not just those that have the matching email address. +Dadurch wird jeder Commit umgeschrieben, um Ihre neue Adresse zu erhalten. +Da die Commits die SHA-1-Werte ihrer Eltern enthalten, ändert dieser Befehl jeden Commit SHA-1 in Ihrem Verlauf, nicht nur diejenigen, die die passende E-Mail-Adresse haben. From ad8758810f694486170eba012dc859897c48d43d Mon Sep 17 00:00:00 2001 From: Dieter Ziller Date: Wed, 8 Jan 2020 19:12:40 +0100 Subject: [PATCH 3/3] Update status.json --- status.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/status.json b/status.json index 3a855b37..e0ebb750 100644 --- a/status.json +++ b/status.json @@ -69,7 +69,7 @@ "sections/rerere.asc": 0, "sections/reset.asc": 0, "sections/revision-selection.asc": 100, - "sections/rewriting-history.asc": 0, + "sections/rewriting-history.asc": 100, "sections/searching.asc": 100, "sections/signing.asc": 100, "sections/stashing-cleaning.asc": 100,