#Day 11 - Advance Git and GitHub Part 2

Passionate AWS Developer | DevOps Engineer with a strong background in cloud architecture and solutions engineering. Leveraging the power of Amazon Web Services (AWS), knowledge of the AWS global infrastructure, design and implement robust cloud-based solutions that align with clients' specific needs.
Git Stash:
Git stash is a command that allows you to temporarily save changes you have made in your working directory, without committing them. This is useful when you need to switch to a different branch to work on something else, but you don't want to commit the changes you've made in your current branch yet.
To use Git stash, you first create a new branch and make some changes to it. Then you can use the command git stash to save those changes. This will remove the changes from your working directory and record them in a new stash. You can apply these changes later. git stash list command shows the list of stashed changes.
You can also use git stash drop to delete a stash and git stash clear to delete all the stashes.
Cherry-pick:
Git cherry-pick is a command that allows you to select specific commits from one branch and apply them to another. This can be useful when you want to selectively apply changes that were made in one branch to another.
To use git cherry-pick, you first create two new branches and make some commits to them. Then you use git cherry-pick <commit_hash> command to select the specific commits from one branch and apply them to the other.
Task 01:
Create a new branch and make some changes to it.
Create anew branch by using command: git checkout -b dev

Make some changes to the file in dev branch.

Suppose In the middle of work, your team urgently requests you to handle an important task in the main branch. To handle this situation without losing your progress, you can utilize the “git stash” command to save your changes without committing them.

Use the following command to switch to the main branch and proceed with important tasks.

Now that our crucial task is completed, let’s switch back to the dev branch to continue our work. Use the git stash pop command to retrieve the changes we stashed earlier and apply them on top of the new commits.


Task 02:
Rebase and commit messages:
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”


Add another line- Line3>> This is the advancement of the previous feature
Commit this with message “ Added feature2.2 in development branch”

Add 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).
Create a prod branch and use git rebase to include all the commits from the dev branch into the prod branch.

Task 03:
In Production branch Cherry pick Commit “Added feature2.2 in development branch” and added below lines in it:
Switch to the production branch. And cherry-pick the commit “Added feature2.2 in development branch” using the command git
cherry-pick <commit-hash>.
Line to be added after Line3>> This is the advancement of previous feature

- Commit: Optimized the feature




