Table of contents
Git Stash:
Git stash
is a command in Git that allows you to temporarily save changes that are not yet ready to be committed. When you run git stash
, Git will save your changes in a "stash" - essentially a stack of saved changes - and restore your working directory to the state it was in before you made the changes. This allows you to work on other changes or switch to a different branch without having to commit your changes or lose your progress.
Cherry-pick:
git cherry-pick
is a Git command that allows you to apply a single commit from one branch to another branch. It is useful when you want to apply a specific change from one branch to another without merging the entire branch.
Task-01
Create a new branch and make some changes to it.
Use git stash to save the changes without committing them.
Switch to a different branch, make some changes and commit them.
Use git stash pop to bring the changes back and apply them on top of the new commits
Below is the command prompt with output how to achieve the task
Task-02
In version01.txt of development branch add below lines after “This is the bug fix in development branch” that you added in Day10 and reverted to this commit.
Line2>> After bug fixing, this is the new feature with minor alteration”
Commit this with message “ Added feature2.1 in development branch”
Line3>> This is the advancement of previous feature
Commit this with message “ Added feature2.2 in development branch”
Line4>> Feature 2 is completed and ready for release
Commit this with message “ Feature2 completed”
All these commits messages should be reflected in Production branch too which will come out from Master branch (Hint: try rebase).
Below is the command prompt with output how to achieve the task
Task-03
In Production branch Cherry pick Commit “Added feature2.2 in development branch” and added below lines in it:
Line to be added after Line3>> This is the advancement of previous feature
Line4>>Added few more changes to make it more optimized.
Commit: Optimized the feature
Below is the command prompt with output how to achieve the task
#Git #DevOps #Github
Please free to write your thoughts and can connect with me on LinkedIn