774 B
774 B
git add, commit & status
Goal
Learn to stage changes, commit them, and inspect repository status.
Start with Untracked Changes
cd ~/lab-git-essentials/my-first-repo
echo "Some notes" > notes.txt
git status
Stage Files
git add README.md notes.txt
git status
Commit with a Message
git commit -m "Add README and notes"
git status
Make and Review Further Changes
echo "Another line" >> notes.txt
git status
git add -p notes.txt # interactively stage hunks (optional)
git commit -m "Update notes with another line"
Good Commit Messages
- Subject line in imperative mood (<= 50 chars)
- Optional body explaining the why (wrap ~72 columns)
Outcome
You can stage, commit, and check status confidently.