Diffs between working directory and staged

Say you have modified files README.md and code.c.

You’ve added README.md to the index (i.e. git add README.md) but code.cis still in the Working Directory.


git diff will only show the diff for code.c

To see the diff for README.md use:

git diff --staged

Now, if we change README.mdagain, this change is in the working directory.

Note: --cached is synonymous with --staged.




Getting to grips with git – the stash, working directory, index, local repo, remote repo

When starting git it’s really helpful to know there are a bunch of locations your source can exist. These are the:

  •  stash
  • working directory
  • index
  • local repo
  • remote repo

I don’t know if this cheat sheet helps or just overwhelms but some may find it useful: http://www.ndpsoftware.com/git-cheatsheet.html#loc=workspace


git stash

The docs say:

git-stash - Stash the changes in a dirty working directory away


but there are plenty of ambiguities here.


What exactly does stash mean?

And what’s a dirty working directory?

Say you’ve got this:

in your current directory your gut reaction might be that it will store your changes to both A and B. After all you’ve changed both and they’re both in your working directory.

That’s not the case:

B is ignored. You need to add it to the repo to stash it.

To stash B, use git stash -u


Note: a dirty working directory would seem to indicate a changed file in the current working directory. It isn’t.

dirty state means modified tracked files and staged changes


working directory is a repository created with the git init command.




Useful discussions:



View stash

List stashes with:

git stash list

View contents of stash with:

git stash show -p stash@{0}


Apply stash

Apply stash with:

git stash apply stash@{0}

Note that this won’t remove the stash from the list.


If you attempt to stash it again, you’ll just add another identical entry into your stash list.

To remove it from the list use:

git stash drop stash@{0}