Staging Changes and Making Commits

Create the first file in project-notes. You will see how an edit becomes part of a recorded version.

On this page

Edit a file in the working tree

The working tree contains the files you are editing. Create README.md with this command in Git Bash, macOS, or Linux, or create the file in an editor. Git reports it as untracked until you add it.

printf '# Project Notes\n' > README.md
git status --short

Choose what to include in the next commit

git add copies the current file contents into the staging area. git diff --staged shows what the next commit will include. If you edit the file again after staging it, stage it again to include the latest edit.

git add README.md
git diff --staged

Record and inspect the first commit

A commit records the staged snapshot in the local repository. Use a message that describes the change. git log --oneline should show the new commit and its abbreviated ID. During later edits, git diff shows unstaged changes to tracked files.

git commit -m "Add project README"
git log --oneline
git status

Official references