Key points
- The staging area lets you construct your next commit in a logical, structure fashion.
git reset HEAD <filename>
lets you restore your staging environment to the last commit state.
- Moving files around and deleting them from the filesystem, without notifying Git, will cause you grief.
git mv
moves files around and stages the change, all in one action.
git rm
removes files from your repository and stages the change, again, in one action.
- Restore deleted and staged files with
git reset HEAD <filename>
followed by git checkout HEAD <filename>
git reset HEAD --hard
This will undo any changes you've made to tracked files and restore deleted files
git clean -fd
This will delete any new files (without .gitignore file) that were added since the last commit, git clean -x
will delete ignored files.