I\'m looking to split a commit up and not sure which reset option to use.
I was looking at the page In plain English, what does "git reset" do?, but I real
A lot of the existing answers don't seem to answer the actual question. They are about what the commands do, not about what you (the user) want — the use case. But that is what the OP asked about!
It might be more helpful to couch the description in terms of what it is precisely that you regret at the time you give a git reset
command. Let's say we have this:
A - B - C - D <- HEAD
Here are some possible regrets and what to do about them:
git reset --soft A
. I can now immediately commit and presto, all the changes since A are one commit.
git reset --mixed A
. The commits are gone and the index is back at A, but the work area still looks as it did after D. So now I can add-and-commit in a whole different grouping.
Make a new branch otherbranch
, and then git reset --hard A
. The current branch now ends at A, with otherbranch
stemming from it.
(Of course you could also use a hard reset because you wish B, C, and D had never happened at all.)