The daily loop — status, add, commit, log
Ninety percent of your time with GIT is these four commands. You'll also learn what belongs in one commit and how to write a message worth reading.
What you'll learn
- You can run the status → add → loop without hesitating
- You can judge what belongs in a single commit
- You can read and find the commit you want
This step uses the three areas from step 2: → (git add) → → (git commit) → . The daily loop is simple: see what you changed with git status, pick what goes into this commit with git add, nail it down with git commit, then read the history with git log. You'll repeat this dozens of times a day on the job, so the goal of this step is to repeat it until your hands do it without you.
One commit should carry one logical change. If you fix a login and also tidy the indentation that was bothering you, you can no longer just the bug fix later. git add -p lets you stage parts of a single file, so get into the habit of splitting work at commit time even when you did it all at once.
A commit message is a letter to your future self and your teammates. Keep the first line around 50 characters, say what you did in the imperative, and if needed add a blank line and why. A type prefix — fix: redirect home after login — follows the convention and makes history machine-readable too. Messages like "fix" or "work" tell nobody anything.
Understand it easily
A commit is like a page in a photo album with a caption. git status shows which photos are new, git add chooses the photos for the page, git commit glues them in with a caption, and git log flips through the album.
Commands for this step
Don't just read them — type them into a real . Your hands have to remember, not your eyes.
git add <file>- Stage a file you changed.
git add -p- Stage only chosen chunks inside a file — this is how you split commits.
git commit -m "fix: 로그인 리다이렉트 오류 수정"- Nail the staged changes into history. Say what you did and, if it matters, why.
git log --oneline --graph --all- Read history one line per commit with a graph. If the screen stops and doesn't end, press
qto get out.
More options — open when you need them
A file is one already knows: it was in the last commit, or you staged it with git add. A brand-new file is untracked until you add it — git status lists it under "Untracked files". The commands below differ in which files they pick up.
git add .- Stage new, changed and deleted files in the current folder and everything below it.
git add -A- Stage every change in the whole repository, wherever you are — new, changed and deleted files.
git add -u- Stage changes and deletions of tracked files only. New (untracked) files are left out.
git commit- Without
-m, Git opens a text editor for the message: the first line is the title, then a blank line and the details. Save and close the editor to finish the commit. git commit -m "title" -m "body"- Each
-mbecomes its own paragraph — the first is the title, the second the body. git commit -am "message"- Stage every changed or deleted tracked file and commit in one go. New files are not included —
git addthem first.
Common mistake and how to fix it
Running git commit without -m and getting stuck in a strange editor screen. In Vim, press Esc, then type ZZ (capital Z twice) to save the message and leave. In , where ^X Exit shows at the bottom, press +O, Enter, then Ctrl+X. Next time, write the message on the with -m.
You mark this yourself. Nothing is graded here.
Mark this step as understood?
This cannot be undone yet, so mark it only when you really understand.
Marked as understood
You mark this yourself. Nothing is graded here.