Checking Status and History

git status shows what has changed; git log shows the commit history.

Syntaxgit status git log --oneline

Two commands you will run constantly:

git status

Shows which files are staged, which are modified but unstaged, and which are untracked. Run it often to know exactly where you stand.

git log

Lists commits, newest first, with the author, date, and message. Handy flags:

  • git log --oneline — one compact line per commit.
  • git log --graph --oneline --all — a visual branch graph.
  • git log -p — show the full diff of each commit.

Example

Example · bash
git status

git log --oneline
# a1b2c3d Fix typo in heading
# 9f8e7d6 Add home page and base styles

# Visual history across all branches
git log --graph --oneline --all

When to use it

  • A developer runs git status before every commit to catch accidentally staged files like .env or compiled binaries.
  • A team lead uses git log --oneline --graph to understand the full branch topology before approving a merge.
  • A developer uses git log --author to audit all commits made by a specific contributor during a sprint.

More examples

Check working tree status

Shows which files are staged for the next commit, which are modified but not staged, and which are untracked.

Example · bash
git status
# On branch main
# Changes to be committed:
#   modified:   src/app.py
# Untracked files:
#   build/

View compact one-line history

Displays the last ten commits as a compact list, each with its short hash and message for quick scanning.

Example · bash
git log --oneline -10
# e4a1f3c Add password reset endpoint
# 9c2b88a Fix null pointer in parser
# 3d0e11f Refactor database connection pool

Graph all branches with author

Renders a visual branch graph showing how all refs (branches, tags) relate to the commit tree.

Example · bash
git log --oneline --graph --decorate --all
# * e4a1f3c (HEAD -> main) Add password reset
# | * 7b2c9d1 (feature/login) Add OAuth login
# |/
# * 3d0e11f Refactor database connection pool

Discussion

  • Be the first to comment on this lesson.