Skip to content

Commit 1ab5006

Browse files
HonkingGooseben
andauthored
Rewrite of proposed section by Ben
Co-authored-by: Ben Straub <[email protected]>
1 parent 3fa7295 commit 1ab5006

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

book/07-git-tools/sections/rewriting-history.asc

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,22 +310,15 @@ pick 461cb2a This commit is OK
310310
drop 5aecc10 This commit is broken
311311
----
312312

313-
[CAUTION]
314-
====
315-
Do not delete/drop a commit that other commits depend on!
316-
It's a bad idea to drop the first commit in the `rebase -i` script list.
317-
The following commits depend on the first commit being present, as the root of all changes that follow.
318-
====
313+
Because of the way Git builds commit objects, deleting or altering a commit will cause the rewriting of all the commits that follow it.
314+
The further back in your repo's history you go, the more commits will need to be recreated.
315+
This can cause lots of merge conflicts if you have many commits later in the sequence that depend on the one you just deleted.
319316

320-
Avoid doing this:
321-
[source,console]
322-
----
323-
drop 5aecc10 This commit is broken
324-
pick c6be4c9 This commit is OK but depends on changes made in 5aecc10
325-
----
317+
If you get partway through a rebase like this and decide it's not a good idea, you can always stop.
318+
Type `git rebase --abort`, and your repo will be returned to the state it was in before you started the rebase.
326319

327-
Git will complain about the broken state, and ask you to resolve the conflicts manually.
328-
You can also just back out of the rebase by using `git rebase --abort`.
320+
If you finish a rebase and decide it's not what you want, you can use `git reflog` to recover an earlier version of your branch.
321+
See <<ch10-git-internals#_data_recovery>> for more information on the `reflog` command.
329322

330323
[NOTE]
331324
====

0 commit comments

Comments
 (0)