You edited three files on Monday, got pulled onto something else, and never committed. Today you open the repository and wonder what half-finished change is sitting in there. Or you don’t open it, and it waits.
Git can tell you what is changed but not committed. It answers one working folder at a time, so start there, then ask all of them at once. This is the other half of finding unpushed commits: a commit you haven’t pushed and a change you haven’t committed are both work that exists only on your laptop.
Ask one repository
From inside the repository:
git status --short --untracked-files=normal
--untracked-files=normal is spelled out because a Git setting (status.showUntrackedFiles) can hide new files, and you want them in this answer.
M src/cart.js
M src/tax.js
?? notes.txt
?? scratch/
The two columns on the left are the state. A letter in the first column is staged, ready for the next commit. A letter in the second is changed but not staged. ?? is a new file Git doesn’t track yet, and a new folder shows as one line.
No output means the working folder is clean.
Every repository in a folder
If your repositories sit side by side in one folder (~/code/web, ~/code/api), one loop asks each of them:
for d in ~/code/*/; do
[ -d "$d.git" ] || continue
git -C "$d" worktree list --porcelain | sed -n 's/^worktree //p' |
while IFS= read -r wt; do
status=$(git -C "$wt" status --porcelain --untracked-files=normal) || continue
[ -n "$status" ] || continue
echo "${wt#"$HOME"/}: $(echo "$status" | wc -l | tr -d ' ') changed"
done
done
code/api: 1 changed
code/web: 3 changed
code/web-fix: 1 changed
Each line is a working folder with something uncommitted, and the number of files or new folders involved. Clean ones print nothing.
[ -d "$d.git" ]keeps the loop to a repository’s main folder. A linked worktree has a.gitfile instead and is reached through the next line.git worktree listnames every working folder the repository has, wherever it sits on disk. Hereweb-fixis a worktree ofweb.--porcelainis the stable format meant for scripts. Its lines are the same as--shortwithout-b.|| continueskips a folder Git can’t read, for example a worktree whose folder was deleted.
Why the worktree line matters
Two other how-tos here skip worktrees on purpose. For branches that is right: worktrees share their repository’s branches, so listing them again repeats every row.
Uncommitted changes don’t work that way. Each worktree has its own files, its own index and its own changes. web-fix above holds an edit that git status in web never shows. If the loop skipped worktrees, that edit would be exactly the kind you forget.
Where the loop stops working
- Repositories outside the folder. It looks one level deep in one folder. A repository cloned somewhere else, or nested a level down, is never asked.
- Ignored files. Files your
.gitignorecovers don’t appear, including local config and build output you might still care about. - Stashes. Work you stashed isn’t a change in the working folder.
git stash listshows it, one repository at a time. - It only reports. You still open each folder to see what changed, and decide whether to commit, stash or discard it.
- You have to remember to run it. The changes you forgot are the ones you forget to check for.
Or let your Mac keep watch
Once a change is committed, the other half is the commits that haven’t been pushed. push& (Pushand) is a Mac menu bar app that watches the repositories and worktrees you choose and keeps a count of the commits waiting to be pushed. Expand a repository to read them, click a ready branch to push. Free for 3 repositories, and every install starts with a 14-day trial, no card and no account.