git diff and git stash save all uncommitted changes (work area and temporary area) to the stack for subsequent recovery of the current working directory

Posted May 27, 20201 min read

  1. View the changes

$git diff #Compare work area(not git add) and temporary area(after git add)
$git diff --cached # Compare the staging area(after git add) and the repository(after git commit)
$git diff HEAD #Compare the workspace(not git add) and the repository(after git commit)
  1. Hide modification

$git stash #hide modification
$git stash list #View stash content
$git stash apply #Restore changes, stash content will not be deleted
$git stash drop #Delete the content of stash
$git stash pop #Restore changes and delete stash content

Note:The newly added files will not be stored if you execute stash directly, that is, files that are not in git version control cannot be saved by git stash.