Day 11 Task: Advance Git & GitHub for DevOps Engineers: Part-2
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.
Git 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 the 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.
Use git stash to save the changes without committing them.
Task 02:-
In Production branch Cherry pick Commit “Added feature2.2 in development branch” and added below lines in it
Line4>>Added few more changes to make it more optimized.
Commit: Optimized the feature
In the above conflict, the changes from both branches (HEAD
and 073b6c6
) are conflicting. You need to decide which version to keep.