This means we can make a new commit again now, by just running another git commit. We don't really need it (although it may come in handy), because the -soft flag to git reset keeps the index / staging-area untouched (along with the work-tree). What happens to N? The same thing that happened to C before: it's saved for a while through the reflog. Now branch points to C, which points back to P. So, we now run git reset -soft which does this: C <- branch (Specifically, this is short for 2 which means "where currentbranch pointed one step ago", which was "to commit C".) ![]() You can find commit C through the reflogs, and this is what the syntax does. P-C chain is still in there, fully intact. We can't quite do this-we can't change N Git can never change any commit (or any other object) once it's stored in the repo-but note that the. What you realized you want, after the git commit -amend, is to have the chain look instead like. Note that commit C is still in the repository it's just been shoved aside, up out of the way, so that new commit N can point back to old parent P. When we use -amend, we get this instead: C We start with a commit graph that ends in P-C, pointed-to by branch. Pictorially, we can draw what happened this way. It still writes a new commit as before, but in step 3, instead of writing the new commit with parent = C, it writes it with parent = P. When using -amend Git changes the process a bit. ![]() Update the branch with the new commit ID N.Write a new commit with parent = C and tree = T.This produces another ID let's call this ID T (for Tree). Turn the index (aka staging-area) into a tree.Note that this current commit has a parent commit let's call its ID P (for Parent). Read the ID (SHA-1 hash, like a123456.) of the current commit (via HEAD, which gives us the current branch).When you make a new commit, Git usually 1 uses this sequence of events: Here's the two command sequence to do just what you want: git reset -soft commit -C an explanation of how this works.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |