# Advance Git & GitHub: Part-2

## Introduction

**Git Stash**

Git stash is a feature in the Git version control system that allows you to save your current changes in a temporary area so that you can switch to a different branch or perform other operations without committing your changes. It's particularly useful when you want to switch to a different branch to work on another task or update your codebase without committing incomplete or experimental changes.

The basic concept behind `git stash` is to store the modified and staged (but not yet committed) changes in a "stash stack," which acts as a stack of saved states. You can later apply these stashed changes back to your working directory or even move them to a different branch.

**Cherry-pick**

`git cherry-pick` is a Git command that allows you to apply the changes introduced by one or more existing commits to your current branch. It's like manually selecting specific commits and adding them to your branch's history. This can be useful when you want to incorporate specific changes from another branch or commit without merging the entire branch.

**Resolve conflicts (if any)**

If the cherry-picked commit introduces conflicting changes with your current branch, Git will pause the cherry-pick process and ask you to resolve the conflicts manually. After resolving the conflicts, save the changes, and continue with:

```bash
git cherry-pick --continue
```

## 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.
    

Created a new git branch and named new\_branch, Created newfile.txt

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690811405211/7be0e7fc-20d4-4977-997e-111940430602.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690811530618/fa8440f2-209d-4eb1-85ee-ceffb4aaca33.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690811736377/c5048838-7794-4aea-8612-fa6ecafb5833.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690812253978/06624f54-e111-4b47-9fa4-e3e9e639e59a.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690812310891/e13b0404-a6e3-4aca-9923-6d99123a3881.png align="center")

## Task-02

* In version01.txt of the development branch add the below lines after “This is the bug fix in development branch” that you added in Day10 and reverted to this commit.
    
* Line2&gt;&gt; After bug fixing, this is the new feature with minor alterations”
    
    Commit this with the message “ Added feature2.1 in development branch”
    
* Line3&gt;&gt; This is the advancement of the previous feature
    
    Commit this with the message “ Added feature2.2 in development branch”
    
* Line4&gt;&gt; Feature 2 is completed and ready for release
    
    Commit this with the message “ Feature2 completed”
    
* All these commits messages should be reflected in the Production branch too which will come out from the Master branch (Hint: try rebase).
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690813091263/eec68fa1-4d68-42eb-a080-abe7342e2160.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690813099538/6992d40d-585b-4821-8131-adc4dbdabb87.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690813182099/52958732-559f-449b-bea1-5eb305831467.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690813235651/aeb40f6d-1736-469d-ad6f-ce8bb3452f5c.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690813263842/8a745c23-4eba-4fa9-9df7-ff43da18a082.png align="center")

## Task-03

* In the Production branch Cherry pick Commit “Added feature2.2 in development branch” and added the below lines in it:
    
* The line to be added after Line3&gt;&gt; This is the advancement of the previous feature
    
* Line 4&gt;&gt;Added a few more changes to make it more optimized.
    
* Commit: Optimized the feature
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690814320429/1e1558dc-3164-4fb3-8494-ee60fa047ca5.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690814339282/5c20b776-78a8-440e-b96a-8f57f2876e0c.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1690814345454/91f76296-21cf-4a1d-b773-f5be3d0f616e.png align="center")

📚 Congratulations on completing your blog on Git and GitHub! We hope this journey has been enlightening and has expanded your understanding of version control and collaborative development.

🤝 Embracing Git and GitHub opens up a world of possibilities for software developers and teams. By leveraging the power of version control, you can confidently experiment, collaborate, and make improvements without the fear of losing your work or disrupting others.
