0

I am trying to reorder my two last commits.

I have order like

449b581 latest commit 8aa0c5a commit prior to latest commit 

and I'm got in to rebase using comand

git rebase -i HEAD~2 

which leads me to VIM editor with text

pick 8aa0c5a commit prior to latest commit pick 449b581 latest commit # Rebase a716b77..449b581 onto a716b77 # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out 

After swithcing commits to

pick 449b581 latest commit pick 8aa0c5a commit prior to latest commit 

and exiting VIM I get

$ git rebase -i HEAD~2 Successfully rebased and updated refs/heads/master. 

but my log is still the same. How come? I tried different order of pick commands after seeing the first time didn't go as expected. ;) There is no error, no merge pending or something like that. I had to stash few files before doing reodering the commits. Did it affect the rebasing?

btw, all I want to do is push my last commit to remote repository but I don't want the previous commit goes there too. Am I on the right track or I can achieve this without reordering commits?

1
  • looks like you are on the right track, check the"answer" of @TheGeorgeous. Commented Jul 27, 2015 at 7:38

1 Answer 1

2

Did you save the file before exiting vim? You may have simply exited without saving, so the changes would have been lost and the commit order would have been the same. Hence no change after the rebase.

Sign up to request clarification or add additional context in comments.

1 Comment

Your answer is like your nick ;) I was using :q! command to quit the editor, didn't think what it actually means. Pretty obvious behavior when I look at it with knowing this :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.