In Android's gerrit ex: link, to download the patch, I see 4 options.
What is the difference between them?
Here is what I think of them. Please clarify
I know that pull and checkout are different from cherry-pick. But how are they different?
Besides being used for different tasks, the most significant difference is that git-cherry-pick changes the history of a branch, while git checkout is being used only to jump to a specific point in time (a specific commit) in the branch's history, without changing it.
With checkout you switch to a specific revision. You want to do this, if you just started using this. Now if you are already following a remote branch, you might only need to update your local branch. That's what pull does for you.
git cherry-pick is a powerful command that enables arbitrary Git commits to be picked by reference and appended to the current working HEAD. Cherry picking is the act of picking a commit from a branch and applying it to another. git cherry-pick can be useful for undoing changes.
The git checkout command lets you navigate between the branches created by git branch . Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.
You are right about the first one. Here are the rest of them:
Checkout: Fetches the latest changes. You should already have this repo downloaded. It does not merge those new changes but makes your working directory reflect them. And a name-less commit is created to include these changes in your working directory. And a detached HEAD pointing to it. You can merge them at your leisure later.
Pull: Fetches the changes AND merges them into the local branch of the same name.
Cherry-pick: Fetches the commit and plays it on top of the current local branch, thus creating an entirely new commit which happens to have same changes as the one it fetched.
They are a little different than what they actually mean in git
. checkout
and cherry-pick
don't automatically fetch the changes. checkout
just takes HEAD
to a commit you specify, thus making working directory exactly as it was at that commit. Likewise, cherry-pick
is used to replay commits which you already have local access to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With