Staging area is like cardboard box when moving house
git commit // take you into vim
I // Go into insert mode
Escape // Quit insert mode
:wq // Save and quit vim
Key points
- A commit is essentially a snapshot of the particular state of the set of files in the repository at a point in time.
- The working tree is the collection of project files that you work with directly.
git status
shows you the current state of your working tree.
- Git thinks about the files in your working tree as being in three distinct states: unmodified, modified and staged.
git add <filename>
lets you add changes from your working tree to the staging area.
git add .
adds all changes in the current directory and its subdirectories.
git add <directoryname>/\\*
lets you add all changes in a specified directory.
git diff
shows you the difference between your working tree and the staging area.
git diff --staged
shows you the difference between your staging area and the last commit to the repository.
git commit
commits all changes in the staging area and opens Vim so you can add a commit message.
git commit -m "<your message here>"
commits your staged changes and includes a message without having to go through Vim.
git log
shows you the basic commit history of your repository.
git log -p
shows the commit history of your repository with the corresponding diffs.