# Advance Git & GitHub for DevOps Engineers: Part-2

## 📌 Git Stash

Git stash is a feature in the version control system Git that allows you to save and temporarily store changes that you don't want to commit immediately but also don't want to lose. In when the middle of the work we have to switch to another branch so at the time with the help of git stash we save our previous work but not commit and go to another branch to not lose the previous work and neither commit.

## 📌 Cherry-pick

Cherry-pick is used to specific changes from one branch into another without merging the entire branch. sometimes we commit accidentally made to the wrong branch. we can switch to the correct branch and cherry-pick the commit to where it should belong.

## 📌 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 Git stash command

Create a new branch and make some changes to it. Use git stash to save the changes without committing them.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690782549400/e011a62d-8b63-4ad1-b9e9-6213cbbad0b1.png align="center")

Switch to a different branch, make some changes, and commit them.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690782744520/f11c3a6c-b588-4820-9850-2324e168ce17.png align="center")

Use git stash pop to bring the changes back and apply them on top of the new commits.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690782770363/72de52ec-4a17-4bbf-9cb3-ba30f8954693.png align="center")

## 📌 Task-02 Git rebase command

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.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690789948740/bd6468f8-af71-4c1b-84aa-f6c0fccdefba.png align="center")

All these commits messages should be reflected in Production branch too which will come out from Master branch

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690790076949/49d27a8c-fc1e-48e8-9f9b-601ab4008984.png align="center")

## 📌 Task-03 Git cherry-pick command

In Production branch Cherry pick Commit “Added feature2.2 in development branch” and

added below lines in it: Line to be added after Line3&gt;&gt; This is the advancement of previous feature

Line4&gt;&gt;Added few more changes to make it more optimized. Commit: Optimized the feature

```basic
Command 

git cherry-pick <commit id>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690795516581/9603a26f-ec15-4ce0-aaf5-229cd5670149.png align="center")
