/    /  Git – Cherry-Pick

Git cherry-pick 

 

git cherry-pick” is a Git command that allows you to apply changes from a specific commit to your current branch. This can be useful when you want to apply a change from one branch to another branch that does not have the change yet, or when you want to apply changes from multiple commits individually.

Here’s how you can use “git cherry-pick”:

Checkout the branch where you want to apply the changes.

Git cherry-pick

As we have created a file ‘cherryfile’ and passing it through  the staging area and we have committed it. Now the file ready to merge in the master branch. In order to merge this file using cherry-pick , first we have to copy the log of the file by following the command git log and merge there using the below command  of the dev1.

git cherry-pick <commit-ID>
  • Run the following command: “git cherry-pick <commit-ID >”, where “commit-ID ” is the identifier of the commit that you want to apply.
  • Git will apply the changes from the specified commit to the current branch, and create a new commit with the applied changes.

After getting into the master branch. Do the following :

Git cherry-pick

As the file from dev1 has been merged into the master without doing merge and only by using the git cherry-pick command.

  • Note that “git cherry-pick” only applies changes to the current branch, and does not merge the entire branch. Also, if the changes from the specified commit conflict with the changes in your current branch, you may need to resolve the conflicts before you can continue.