How does git stash work internally, and where does the data go when you "pop" it?

Last updated 6 July 2026

  • git stash saves uncommitted changes as real commit objects (one for the working tree, one for the index, joined by a merge-like commit parented on HEAD), not on any branch.

  • The ref refs/stash points to the latest stash. Its reflog holds the stack (stash@{0}, stash@{1}, ...).

  • On pop, Git merges those changes into the working tree, then drops the reflog entry so the commits become unreachable and eligible for garbage collection.

  • https://www.reddit.com/r/cscareerquestions/comments/bxxwfc/what_are_some_behavioral_questions_you_have_been/
  • https://www.reddit.com/r/rails/comments/1shfrbq/3_years_rails_dev_but_failed_basic_interview/
  • https://www.reddit.com/r/cscareerquestions/comments/u7z2xh/how_often_do_developers_look_at_git_trees/
All Git interview questions