What is the difference between the commands 'git diff –staged' and 'git diff –cached'

I have just started learning git. I have a confusion between the commands git diff --staged and git diff --cached.

  • How can I call 'git pull' from within Python?
  • IntelliJ IDEA GitHub integration creates the repository, but gets “couldn't authorize” error trying to push
  • Project not under version control - Imported from EGit repo
  • How to push without a pull?
  • How to get blame information of a line of code on a repository from github API
  • gitolite permissoins with branches and folders
  • How to push my changes back to the source code in git
  • How to stop git from breaking encoding on checkout
  • git hooks push and local commits
  • Get only sub-directories with Git?
  • git-subtree pull complications
  • How to prevent that the password to decrypt the private key has to be entered every time when using Git Bash on Windows?
  • 2 Solutions collect form web for “What is the difference between the commands 'git diff –staged' and 'git diff –cached'”

    In old version of git the staging area is refereed to as cache/stage area.
    Today it’s being called index.

    From the docs:

    --staged is a synonym of --cached.

    Stage/cache/index are all synonyms for the staging area. It simply depends on the git version you use. It was change to index along the way (and today it’s called index), but they are still a few command which use --cached along the way, like git diff, git rm --cached etc.

    Git Workflow

    There is no difference between these two. From git diff docs:

    --staged is a synonym of --cached.

    You can read more about it in SO docs.

    Git Baby is a git and github fan, let's start git clone.