What is the difference from drop
in the Git interactive rebase and just deleting the line of the commit?
(drop) — If you remove a commit from the interactive rebase file, or if you comment it out, the commit will simply disappear as if it had never been checked in. Note that this can cause merge conflicts if any of the later commits in the branch depended on those changes.
Running rebase in interactive mode and executing subcommands like squash or drop will remove commits from your branche's immediate log.
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.
To do this, simply delete all commits and actions (i.e. all lines not starting with the # sign) and the rebase will be aborted!
There is no difference by default; it's just another way to say the same thing.
But, if you set rebase.missingCommitsCheck
to warn
or error
, then removing a line will trigger a warning (useful for detecting a messed-up cut-and-paste).
Then setting the line to drop
explicitly tells Git that you want to drop that commit, and no warning is shown for it.
There is in fact another small difference:
You can explicitly "drop" all commits. The effect will be the same as a reset.
However if you just delete all lines, then git will tell you "Nothing to do".
Usually you would not use rebase anyway in that case. I learned the difference only when I tried to explain removing a commit with rebase to a co-worker using a dummy commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With