39 lines
774 B
Markdown
39 lines
774 B
Markdown
# git add, commit & status
|
|
|
|
## Goal
|
|
Learn to stage changes, commit them, and inspect repository status.
|
|
|
|
## Start with Untracked Changes
|
|
```bash
|
|
cd ~/lab-git-essentials/my-first-repo
|
|
echo "Some notes" > notes.txt
|
|
git status
|
|
```
|
|
|
|
## Stage Files
|
|
```bash
|
|
git add README.md notes.txt
|
|
git status
|
|
```
|
|
|
|
## Commit with a Message
|
|
```bash
|
|
git commit -m "Add README and notes"
|
|
git status
|
|
```
|
|
|
|
## Make and Review Further Changes
|
|
```bash
|
|
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.
|