Table of contents
Git Stash
Git stash is a useful feature in Git that allows you to save changes you've made to your code without committing them. It's particularly useful when you need to switch to another branch or work on a different feature, but you're not ready to commit your changes yet. With Git stash, you can "stash" your changes away, switch to another branch, work on something else, and then come back to your original changes and reapply them. This can help you keep your code organized and avoid losing important changes.
Cherry-pick
Cherry-pick is a Git command that allows you to pick and apply specific changes from one branch to another. It's like taking a cherry from a tree - you're selecting only the specific commit or changes that you want, rather than merging the entire branch.
Cherry-pick is useful when you want to apply a single commit or a few selected commits from one branch to another. It can help you avoid merging unwanted changes and keep your codebase clean.
To use cherry-pick, you simply identify the specific commit(s) that you want to apply and then use the cherry-pick command to apply them to another branch. This can be a helpful tool for managing your Git workflow and ensuring that only the necessary changes are applied.
Resolving Conflicts
Conflicts can occur when you merge or rebase branches that have diverged, and you need to manually resolve the conflicts before git can proceed with the merge/rebase. git status command shows the files that have conflicts, git diff command shows the difference between the conflicting versions and git add command is used to add the resolved files.
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.
_____________________________________________________________________________________
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.
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).
(Note- Here main - is named dev and dev - is named main)
To change the name of a branch use this command - git branch -m old-name new-name
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
Thank you for reading. I hope you were able to understand and learn something new from my blog.
Happy Learning!
Please follow me on Hashnode and do connect with me on LinkedIn ArnavSingh.