CodeBlanks Logo Icon CodeBlanks

pick reword squash

Learn the pick, reword and squash commands.

pick, reword, and squash

In an interactive rebase todo list, pick replays a commit without changing it. reword keeps the commit's changes but lets you edit its message. squash combines the commit with the previous commit and lets you edit the combined commit message.

pick a12bc34 Add profile page
reword b23cd45 Update profile text
squash c34de56 Fix profile spacing

These commands help turn scattered history entries into a clearer sequence.

Combining commits

The squash command is used with the commit immediately before it in the todo list. During the combination, Git may open an editor for the resulting commit message. This is useful when you want to group multiple commits into one entry.

pick a12bc34 Add checkout page
squash b23cd45 Fix checkout button
squash c34de56 Adjust checkout layout

In this example, three entries are combined into a single commit.

Practice Simplify the commit history

Keep the first commit in the todo list, choose to change the second commit's message, and combine the third commit with the previous entry. Use the commit IDs and messages below.

Starter code

terminal
# İlk commit: pick
# İkinci commit: mesajını düzenle
# Üçüncü commit: öncekiyle birleştir

Sample solution

terminal
pick d12ef34 Add account page
reword e23fa45 Improve account validation
squash f34ab56 Fix account form spacing

Expected output

pick d12ef34 Add account page
reword e23fa45 Improve account validation
squash f34ab56 Fix account form spacing

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 You want to keep a commit's file changes and change only its commit message. Which command should you choose?

  • squash
  • drop
  • pick
  • reword Correct answer

Explanation: reword preserves the commit's changes and lets you rewrite its message.

2 Edit a commit message

Question
reword ____ b23cd45 Update profile text
Answer
reword b23cd45 b23cd45 Update profile text

Explanation: The reword command is used to change the message of the specified commit.

3 Todo list commands

Term Meaning
pick Replays the commit normally
reword Changes the commit message
squash Combines with the previous commit
Mesaj düzenleme Sets the new commit description

All lessons in Advanced