top of page

Welcome
to NumpyNinja Blogs

NumpyNinja: Blogs. Demystifying Tech,

One Blog at a Time.
Millions of views. 

GitHub Desktop for Beginners: Stash Changes and Team Collaboration Using Jupyter Notebook

Oct 21
5 min read

Updated: Oct 23

Introduction

In my previous blog, we learned how to create a repository, work on our own branch, commit changes, push files to GitHub, and create a pull request to merge our work into the main branch.


Now let's look at another common situation we come across when working on a team project.


Suppose we have started working on a file in our local branch, but our work is not yet complete.


Meanwhile, other team members have made changes and merged their work into the main branch.


Now we want to get the latest changes from main without losing the work we have already done in our local work space.


How do we handle this ?

This is where Git Stash comes in to the picture.


In this blog, let's understand how to save our unfinished work temporarily, get the latest changes from main, restore our work, and continue working using GitHub Desktop.

 

What Is Git Stash?

Git Stash allows us to temporarily save our uncommitted changes without creating a commit.


For example, imagine we are working on a file but haven't completed it yet.

Instead of committing incomplete work, we can use Stash to keep our changes aside for some time.

Once we have updated our branch with the latest changes, we can bring back those changes and continue working.


One important thing to remember is that stashed changes are saved locally. They are not pushed to GitHub.

 

Step 1: Make Changes in Your Working Branch

Let's continue with the same repository and branches we used in our previous blog.

We have two branches:

  • main – Contains the latest approved changes from the team.

  • Working branch (lilly) – Our working branch where we make changes.

Now let's say we are working on employee_analysis.ipynb.

  1. Open GitHub Desktop.

  2. Select our repository.

  3. Make sure we are on the Working branch (lilly) branch.

  4. Open employee_analysis.ipynb in Jupyter Notebook.

  5. Make a few changes and save the file.

Now go back to GitHub Desktop.

Under the Changes tab, we can see the changes we made to the file.

But our work is not yet completed, so we don't want to commit it.

At the same time, other team members have already merged their latest changes into main.

We want to bring those changes into our branch without losing our unfinished work.

Let's see how to do that.

 

GitHub Desktop showing uncommitted changes

 

Step 2: Save Your Unfinished Work Using Stash

Before getting the latest changes, let's temporarily save our unfinished work.

  1. Open GitHub Desktop.

  2. Make sure the current branch is you working branch(lilly).

  3. Click Branch from the top menu.

  4. Select Stash All Changes.

 

That's it!

GitHub Desktop saves our uncommitted changes temporarily.

Now, if we look at the Changes tab, the changes we stashed will no longer appear as regular uncommitted changes.

Our work is not lost. It is saved in the stash, and we can restore it later.

 

Branch → Stash All Changes

 

Step 3: Get the Latest Changes from Main

Now that our unfinished work is saved, let's get the latest changes made by our team members.

First, we need to update our local main branch.

  1. Open GitHub Desktop.

  2. Click Fetch origin to check for the latest changes on GitHub.

  3. Select the main branch.

  4. Click Pull origin if new commits are available.

Now our local main branch has the latest changes from GitHub.

What is the difference between Fetch and Pull?

  • Fetch origin: Checks GitHub for new commits and downloads them without changing the files in our current working branch.

  • Pull origin: Downloads and brings the latest changes from GitHub into our current local branch.

Note: If our local branch is already up to date, GitHub Desktop displays Fetch origin instead of Pull origin.

 

Fetch origin and Pull origin in GitHub Desktop


Step 4: Update Your Working Branch

Now we have the latest changes in our local main branch.

But remember, we are working on the lilly branch.

So, we need to bring those latest changes from main into the working branch(lilly).

  1. In GitHub Desktop, select the working branch(lilly).

  2. Click Branch from the top menu.

  3. Select Update from default branch(Brings the latest commits from local main into working branch (lilly).

  4. Complete the update if prompted.

 

If there are any merge conflicts, we need to resolve them before completing the update.

Now our working branch(lilly) contains the latest changes from main.

 

Branch → Update from default branch


Step 5: Restore Your Stashed Changes

We have updated our branch with the latest changes from main.

Now what about the unfinished work we saved earlier?

Let's bring it back.

  1. Open GitHub Desktop.

  2. Stay on your working branch (lilly).

  3. Click View stash on the right

 

  1. Open the Stashed Changes section.

  2. Click Restore.

GitHub Desktop will try to bring our saved changes back into the working branch.

Now we can see our unfinished changes again.

If the restored changes overlap with the latest changes from main, we may need to resolve conflicts.

 

Stashed Changes → Restore


Step 6: Continue Your Work and Commit the Changes

Now we have both the latest team changes and our unfinished work in the working branch(lilly).

Let's continue working.

  1. Open employee_analysis.ipynb in Jupyter Notebook.

  2. Review the latest changes.

  3. Continue working on our file.

  4. Once the work is completed, run the notebook and save the file.

  5. Go back to GitHub Desktop.

  6. Review the changes under the Changes tab.

  7. Enter a commit summary, such as Updated employee salary analysis

  8. Click Commit to working branch(lilly).

  9. Click Push origin to upload our committed changes to GitHub.

That's it!

We have successfully saved our unfinished work in our working branch, updated our branch with the latest team changes, restored our work, and committed the completed changes.

Now we are ready to create a pull request to merge out latest updates into main, as we learned in the previous blog.

 

Commit to Working branch(lilly) and Push origin

 

Step 7: What Happens If Two Team Members Change the Same File?

Sometimes, two team members may make changes to the same file.

For example, we are working on employee_analysis.ipynb in our working branch (lilly), while another team member updates the same file in main.

When we update our branch or restore our stashed changes, Git may not be able to combine some changes automatically. This is called a merge conflict.

If this happens, we need to review the conflicting changes, decide what to keep, and resolve the conflict before continuing our work.

Note: Jupyter Notebook files may need extra care because they are stored in JSON format.

 

Difference Between Stash, Commit, Fetch, Pull, and Push

Before we finish, let's quickly understand the difference between these Git operations.


Conclusion

When working on a team project, sometimes other team members may update the main branch while we are still working on our changes.

In this situation, we can use Git Stash to temporarily save our unfinished work without committing it.

After updating our working branch with the latest changes from main, we can restore our saved work and continue where we left from.

This way, we can keep our branch updated without losing our unfinished changes.

 

Happy Reading..!!

 

 
 

+1 (302) 200-8320

NumPy_Ninja_Logo (1).png

Numpy Ninja Inc. 8 The Grn Ste A Dover, DE 19901

© Copyright 2025 by Numpy Ninja Inc.

  • Twitter
  • LinkedIn
bottom of page