LinuxCommandLibrary

git-local-commits

List commits not yet pushed upstream

TLDR

Show commits that haven't been pushed

$ git local-commits
copy

SYNOPSIS

git-local-commits [options] [revision-range]

PARAMETERS

-r, --remote
    Specify remote (default: origin)

-b, --branch
    Compare against specific remote branch

-a, --all
    Compare against all remotes

--oneline
    One line per commit (like git log --oneline)

--no-merges
    Exclude merge commits

DESCRIPTION

git-local-commits is a utility command, often implemented as a Git alias or script, that displays commits made locally on the current branch which are not yet present on remote-tracking branches. It helps developers quickly identify work that needs to be pushed, avoiding forgotten commits during code reviews or deployments.

Internally, it typically executes a git log variant like git log @{upstream}..HEAD or git log --branches --not --remotes, filtering out merges and shared history. Output includes commit hashes, authors, dates, and messages, formatted similarly to git log.

This command is invaluable in team workflows, CI/CD pipelines, or when switching branches, ensuring no local progress is lost. It assumes a default remote like origin and a tracking upstream; without these, it may show all local commits or fail gracefully.

CAVEATS

Not a core Git command; requires alias setup like git config alias.local-commits 'log @{u}..'. Fails if no upstream tracking branch exists. Output empty if all commits pushed or rebased.

SETUP AS ALIAS

git config --global alias.local-commits 'log --oneline @{u}..'
Invoke as git local-commits.

EXAMPLE OUTPUT

abc1234 (HEAD -> main) Fix bug
xyz7890 Add feature

HISTORY

Emerged as popular Git alias around 2010s in community workflows. No official Git inclusion; variants in tools like git-extras or oh-my-zsh plugins. Usage spiked with distributed team practices post-GitHub rise.

SEE ALSO

Copied to clipboard