When I do git rebase --interactive
, I have six basic commands: pick
, reword
, edit
, squash
, fixup
and exec
.
What does pick
command do? Does it cherry-pick
a commit or does it checkout
it?
When I do git rebase --interactive
, I have six basic commands: pick
, reword
, edit
, squash
, fixup
and exec
.
What does pick
command do? Does it cherry-pick
a commit or does it checkout
it?
From the help article:
pick
pick
simply means that the commit is included. Rearranging the order of the pick commands changes the order of the commits when the rebase is underway. If you choose not to include a commit, you should delete the entire line.
For completeness, here's the other commands as well:
reword
Thereword
command is similar topick
, but after you use it, the rebase process will pause and give you a chance to alter the commit message. Any changes made by the commit are not affected.
edit
If you choose toedit
a commit, you'll be given the chance to amend the commit, meaning that you can add or change the commit entirely. You can also make more commits before you continue the rebase. This allows you to split a large commit into smaller ones, or, remove erroneous changes made in a commit.
squash
This command lets you combine two or more commits into a single commit. A commit is squashed into the commit above it. Git gives you the chance to write a new commit message describing both changes.
fixup
This is similar tosquash
, but the commit to be merged has its message discarded. The commit is simply merged into the commit above it, and the earlier commit's message is used to describe both changes.
exec
This lets you run arbitrary shell commands against a commit.
According to experiments, the pick command in git's interactive rebase works the same way as git cherry-pick --ff. Which, according to the documentation, acts this way:
If the current HEAD is the same as the parent of the cherry-pick’ed commit, then a fast forward to this commit will be performed.
Picking a commit in an interactive rebase means that Git uses the changes made by the commit in question and commits them with the original metadata (message, author, date etc.). So a single pick
looks much like a git cherry-pick
.
On the contrary, pick
does not take the state of the whole repo in the time of the commit like git checkout
would do. Just the changes made by the commit.
Pick is used to include commits.
By default, you are given a table of contents of the commits you selected to rebase. The table of contents is sorted in ascending order by date. Rearranging the order of the pick command changes the order of the commits when you start rebase.
It just uses the commit as it is - that is, no modifications will be made to it.
pick (p for short) is the default action. In this case it would reapply the commit as is, no changes in its contents or message