Git Cherry Pick

Git Cherry-Pick

  • Definition: git cherry-pick applies changes from a specific commit to your current branch.

  • Summary: Copies a single commit to another branch without merging the whole branch.

  • Use Case: Pick select bug fixes or features from another branch without full merge.

Tasks

  1. Ensure you have access to the storage server where the repository is cloned at /usr/src/kodekloudrepos.

  2. Navigate to the /usr/src/kodekloudrepos directory which contains the repository.

  3. Identify the commit on the feature branch with the message Update info.txt.

  4. Merge the identified commit from the feature branch into the master branch.

  5. Push the updated master branch to the remote repository located at /opt/official.git.

Steps

1

SSH into the storage server and get root

ssh natasha@ststor01
sudo su -
2

Navigate to the repo

cd /usr/src/kodekloudrepos/official
3

Fetch all branches to be sure you’re updated

git fetch --all
4

Check out the master branch

git checkout master
5

Find the commit hash from feature branch with message "Update info.txt"

git log feature --grep="Update info.txt" --oneline
6

git cherry-ping commit ha, 0e3895a

git cherry-pick 0e3895a
7

Push the updated master branch to remote

git push origin master

Last updated