I'm trying to use git rebase -i
and it's just confusing... What I want to do is keep the exact contents of my current commit, I just want to show the history as if it was the direct descendant of a previous commit. Say I have these commits where I started working on something in the morning and did a commit before going to lunch and finished it in the afternoon so I wanted to complete it, but I don't want to see the commit where I broke for lunch (this is very simplified, I might commit and branch off to try something else out quick but always mean to introduce the changes back to my branch if it works out):
dbd2032 Add default config file
|
033fca5 ... break for lunch
|
05c4e48 Use config file
So I do a git rebase -i HEAD~2
, which goes back to the grandparent 05c4e48
and gives me this to edit:
pick 033fca5 ... break for lunch
pick dbd2032 Add default config file
Which I change unintuitively to this:
pick 033fca5 ... break for lunch
squash dbd2032 Add default config file
This works, git opens up my editor with the old '... break for lunch' message which I then have to change to 'Add default config file'. After it's done I end up with a new log and git diff dbd2032
shows no differences:
35a5eec Add default config file
|
05c4e48 Use config file
This is counter-intuitive to me because I am not actually picking 033fca5
, I'm specifically removing that commit from history. If I delete the line though I don't get the changes that were introduced in that commit. Git must be doing file diffs along the way to find the changes... Specifically I'm picking the exact tree represented by commit dbd2032
.
Is there any kind of shortcut for what I'm doing? I have the exact contents and commit message I want, I just want to show it as the child of the grandparent (or other descendant).