WEEK 7 · LESSON 9 · TOPIC 2 OF 10 · How It Works

How It Works

Lesson progress

0% Complete

SECTION 1 OF 1

In this topic · 1 sections
  1. Overview

Overview

Suppose you are editing 1.txt on main and the change is only half complete. You then try to switch to development:

git checkout development

Git may refuse because the local change would be overwritten by the checkout. The refusal protects the unfinished work.

Store the pending change temporarily with:

git stash

The modification disappears from the working directory, leaving a clean state that allows the branch switch. The work has not been deleted; it has been moved into the stash.

Now switch branches:

git checkout development

Perform the review or other task, then return:

git checkout main

Restore the most recent stash and remove it from the stash list with:

git stash pop

The unfinished changes reappear in the working directory.