git-local-commits
List commits not yet pushed upstream
TLDR
Show commits that haven't been pushed
SYNOPSIS
git local-commits [options] [branch-to-compare]
PARAMETERS
branch-to-compare
An optional argument specifying the branch to compare against. If omitted, the command typically defaults to comparing against the current branch's configured upstream tracking branch (e.g., origin/main or @{u}). This shows commits that are on the current branch but not on the specified comparison branch.
--stat
(Hypothetical) If implemented, displays a diffstat summary for each unique commit, showing the files changed and the number of lines inserted and deleted.
--pretty=format
(Hypothetical) If implemented, formats the output according to the specified format string, similar to git log --pretty options (e.g., 'oneline', 'fuller', 'format:%h %s').
--no-merges
(Hypothetical) If implemented, excludes merge commits from the output, showing only linear development commits.
-n limit
(Hypothetical) If implemented, limits the number of commits shown to the specified limit.
DESCRIPTION
git-local-commits is not a standard, built-in Git command. It is a common name for a custom script or alias that users create to display commits present only on the current local branch. Its typical purpose is to show changes that have not yet been pushed to its configured upstream remote, or commits that diverge from a specified comparison branch. This command helps developers quickly review their unique local development work, identify unpushed changes, or understand the difference between their current branch and another. Because it is user-defined, its exact functionality, available options, and output format depend entirely on its specific implementation by the user or system administrator. Users often create it to streamline their workflow and provide a clear overview of their unshared contributions.
CAVEATS
This command is not a standard Git command. Its existence and behavior are entirely dependent on a user-defined script or alias within a particular Git installation. There is no guarantee of its presence, consistent functionality, or specific options across different Git environments or users. Users typically implement it themselves using combinations of other Git commands like git log, git cherry, or git diff.
COMMON IMPLEMENTATIONS
Users typically implement git-local-commits by aliasing it to a specific Git command combination in their Git configuration. Common patterns include:
git config --global alias.local-commits 'log @{u}..HEAD'
(Shows commits on HEAD that are not on its upstream branch)
git config --global alias.local-commits '!git cherry -v @{u}'
(Shows commits unique to HEAD that are not in upstream, indicating if they are cherry-pickable)
The @{u} (or @{upstream}) refers to the upstream branch configured for the current branch. If no upstream is configured for the current branch, these commands might fail or yield unexpected results.
PURPOSE AND USAGE
The primary purpose of a git-local-commits command is to provide a concise overview of the work unique to the current branch. It is an invaluable tool for:
- Reviewing changes before performing a git push to ensure only intended commits are shared.
- Identifying commits that might need to be rebased, squashed, or amended for a cleaner history.
- Understanding the exact divergence of a feature branch from its main development line (e.g., main or develop).
- Preparing for code reviews by listing the exact changes to be reviewed.
HISTORY
The need to quickly identify unpushed or locally unique commits is a common workflow requirement for many Git users. Since Git doesn't provide a single, dedicated command for this exact purpose with a user-friendly output out-of-the-box, developers frequently create custom aliases or scripts. The name git-local-commits (or similar variations like git-unpushed) emerged as a popular, community-driven convention for these personal helper tools, addressing a recurring need for better visibility into local development progress.
SEE ALSO
git log(1), git branch(1), git cherry(1), git diff(1), git push(1)