2

I am trying to use the Fixup feature on Magit. I will list a recipe to what it is happening:

(i) - I have a project under version control.

(ii) - My first commit is:

1f61d09 * first commit: add file

The content is:

1 file changed, 1 insertion(+)
random-stack-overflow-questions/fixup-magit-test.txt | 1 +

new file   random-stack-overflow-questions/fixup-magit-test.txt
@@ -0,0 +1 @@
+just a test

(iii) - My second commit is:

a503541 * second commit: changing the original file.

And the diff shows:

modified   random-stack-overflow-questions/fixup-magit-test.txt
@@ -1 +1,3 @@
 just a test
+
+just another test

(iv) - Then, I decided to change the content of my first commit. I could do a new commit, then an interactive rebase, and use it to change the order of the commits moving the third/last commit to be before the second and squashed with the first.

Instead, I decided to use the feature Fixup - since it seems to be designed for situations like this.

Hence, I did the following change:

modified   random-stack-overflow-questions/fixup-magit-test.txt
@@ -1,3 +1,3 @@
-just a test
+just a test FIXED-UP

After writing that change on the file, I staged the change, then I pressed c to commit and, finally, I pressed lower case f (not upper case F) to Instant fixup.

Things do seem to work. Unfortunately, when I pressed git log, this is what I see:

5f91266 * main fixup! first commit: add file

I was not expecting the fixup! to be on git log history. I thought my change would be a fix up on the first commit.

Did I miss something? How can I properly use the fix-up feature?

And what can I do now to achieve what I want? Is it necessary to do an interactive rebase to remove fixup from the git log history?

0

1 Answer 1

5

f just creates the fixup! commit. You wanted the upper-case F -- that ("Instant Fixup") is the variant which automatically performs the rebase after creating the fixup! commit.

You can alternatively use rf to invoke git rebase --autosquash yourself, which is the git option that processes the squash! and fixup! commit messages (see the man page for details).

Be sure to place point on the commit that you wish to squash into before you start -- Magit will use that as the target by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.