CodeBlanks Logo Icon CodeBlanks

Summary - Advanced stash

Combine advanced stash options to manage intermediate work.

Combine advanced stash options

Git stash provides several options for temporarily saving different working states. -u includes untracked files, stash branch creates a new branch from saved changes, and stash show -p displays the saved differences in detail.

git stash -u
git stash branch task-work stash@{0}
git stash show -p

These commands help you preserve unfinished work, continue on a separate branch, and inspect changes.

Practice Build an advanced stash workflow

Add the following operations to the commands array in order: git stash -u to save untracked files, git stash branch experiment-work to create a new working branch, and git stash show -p to inspect differences. Print the commands on separate lines.

Starter code

terminal
const commands = [
    // İleri stash işlemlerini sırala
];

// Komutları yazdır

Sample solution

terminal
let commands = [
    "git stash -u",
    "git stash branch experiment-work",
    "git stash show -p"
];

console.log(commands.join("\n"));

Expected output

git stash -u
git stash branch experiment-work
git stash show -p

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 You want to save new files too and then continue working on a separate branch. Which command sequence is appropriate?

  • git stash -u followed by git stash branch task-work Correct answer
  • git stash pop followed by git clone
  • git stash list followed by git reset --hard
  • git stash show -p followed by git merge

Explanation: <code>git stash -u</code> saves untracked files. Then <code>git stash branch</code> can create a new branch from that entry.

2 Complete the intermediate work workflow

Question
git stash -u
 git stash branch task-work
 git stash show ____
Answer
git stash -u
 git stash branch task-work
 git stash show -p

Explanation: The <code>-p</code> option in the final command displays the detailed diff of the stash changes.

3 Match advanced stash tools

Term Meaning
git stash -u Also saves untracked files
stash branch Applies changes on a new branch
stash show -p Displays line-by-line differences
Patch Text representation of changes

All lessons in Advanced