-1

I have the following screen and need the necessary commands to merge 2 commits.

screenshot of vim running in windows console during an interactive rebase

1
  • 3
    Learn how to use vim or configure git to use a different text editor. Commented Nov 7, 2017 at 14:26

2 Answers 2

2

You should press Escape, then enter :cq (that's : (colon), then c q, followed by Enter).

Now you will have left the vi editor, which is a fine editor, but has a bit of a learning curve.

Instead, go install GitPad, which will set up notepad as the text editor for Git.

Then you can run your rebase command again and you should be placed in the familiar notepad editor. (Now, I concede the notepad is a bit of a mediocre editor, but there's no reason to have to learn a decades old Unix text editor while you're trying to learn a merely decade old Unix version control system.) Once notepad opens, follow the instructions that it gives you - in this case, changing the second line from pick to fixup (or perhaps squash) is probably the right thing.

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

Comments

2

You are in the middle of an interactive rebase, and Git has placed you in the Vim editor so you can interactively tell Git the actions to take.

You should either learn the basics of Vim, or configure Git to use a different editor.

But for now, basically you want to replace the second "pick" with the text "squash" so the two commits are combined into one.

Steps:

  • Press Escape to ensure you are in "command mode"
  • Press j to go down to the second line
  • Press x a few times until the "pick" word is removed
  • Press i to enter "insert mode" and type the text "squash"
  • Press Escape to get out of "insert mode" and back to "command mode"
  • Type :wq to exit the Vim editor

You have now finished the rebase.

3 Comments

Command mode is the default. After pressing j (or just the "down arrow" cursor key), you can then type cw ("change word") to delete "pick" under the cursor and place you in insert mode. Type s (no need to type out "squash" in full) and press Esc. Then type :x followed by Enter to save and exit.
Command mode is the default, but it's a good idea to start with an escape just in case the OP had accidentally entered another mode. I considered using cw for this, but I wanted to keep things as basic and clear as possible.
thank you so much :)) I was stuck in that screen for a half an hour but now it works

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.