I have the following screen and need the necessary commands to merge 2 commits.
2 Answers
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.
Comments
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
:wqto exit the Vim editor
You have now finished the rebase.
3 Comments
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.cw for this, but I wanted to keep things as basic and clear as possible.
gitto use a different text editor.