Checking Status and History
As you work, you’ll often need to know: what has changed? Which files are staged? What commits have I made? Git provides two essential commands for this:
git status and git log.git status – The Current State
git status shows you exactly what’s going on in your repository. It tells you:- Which branch you are on
- Which files are staged (changes to be committed)
- Which files are modified but not yet staged
- Which files are untracked
hello.txt and then run git status again:echo "New line" >> hello.txt
git statusYou’ll see Changes not staged for commit: modified: hello.txt.Short Status
For a compact view, use:
git status -sIt shows symbols like M (modified), A (added), ?? (untracked).git log – The History
git log displays the commit history in reverse chronological order. Each entry shows:- Commit hash (a unique ID)
- Author and email
- Date
- Commit message
git logMaking git log More Useful
You can customize the output:
git log --oneline– shows each commit on one line (hash + message).git log --graph --oneline --decorate– shows a graphical representation of branches.git log -p– shows the actual changes (diff) for each commit.git log --author="Name"– filters commits by author.
Example Workflow with Status and Log
Let’s stage and commit the change we made, then see the updated log:
git add hello.txt
git commit -m "Add a second line"
git log --onelineYou’ll now see two commits.Two Minute Drill
git statusshows the current state: staged, unstaged, untracked files.git status -sgives a compact view.git logdisplays commit history.- Use
git log --onelinefor a quick overview. - Add
--graphto visualize branches.
Need more clarification?
Drop us an email at career@quipoinfotech.com
