CodeBlanks Logo Icon CodeBlanks

stash show -p

Learn the stash diff with stash show -p.

Inspect stash changes

Use git stash show to see which files and changes a stash entry contains. The default view usually provides a short summary of the changes. For a more detailed inspection, you can use the -p option.

git stash show
git stash show -p

The second command displays the changes inside the stash as a diff.

Reading patch output

The output of git stash show -p displays changes line by line. Lines beginning with + represent added code, while lines beginning with - represent removed code.

@@ -1,2 +1,3 @@
 const name = "Ada";
+const role = "Developer";
-console.log(name);

These markers help you understand which code was added or removed in the stash entry.

Practice Stash inspection commands

Add three commands to the commands array: first git stash list, then git stash show, and finally git stash show -p to display detailed changes. Print the commands on separate lines.

Starter code

terminal
const commands = [
    // İnceleme komutlarını ekle
];

// Komutları yazdır

Sample solution

terminal
let commands = [
    "git stash list",
    "git stash show",
    "git stash show -p"
];

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

Expected output

git stash list
git stash show
git stash show -p

Questions and answers

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

1 Which command displays line-by-line changes in a stash entry?

  • git stash list -p
  • git stash show -p Correct answer
  • git stash pop -p
  • git stash branch -p

Explanation: <code>git stash show -p</code> displays the changes in a stash entry as a detailed diff.

2 Display the detailed stash diff

Question
git stash show ____
Answer
git stash show -p

Explanation: The <code>-p</code> option displays stash changes in patch format.

3 Patch markers

Term Meaning
+ Added line
- Removed line
@@ Change range
git stash show -p Detailed diff output

All lessons in Advanced