Alias for unpushed commits, no matter what branch I'm on?

I've got a git alias that looks like this:

        unpushed = log origin..HEAD --pretty=format:'%h %an %s'

Which works great for showing "unpushed" changes when I'm on master. But, this alias doesn't really work right when I'm on a branch.

What would the correct command be to show unpushed changes whether or not I'm on a branch?


If you just want to see the outgoing commits for the current branch, you can use the following:

git config alias.unpushed "log @{u}.. --pretty=format:'%h %an %s'"

This causes git log to show all commits reachable from HEAD excluding those reachable from the upstream branch. The @{u}.. argument is equivalent to @{u}..HEAD, and @{u} is shorthand for the current branch's upstream commit (e.g., origin/foo if the checked out branch is foo).

If you want to see all unpushed commits from all branches, do this:

git config alias.unpushed "log --all --not --remotes --tags --pretty=format:'%h %an %s'"

The above causes git log to walk all references, but stop at (exclude) remote references (e.g., origin/master) and tags. Git doesn't distinguish between local and remote tags, so the above assumes that all tags are remote (this isn't always true, so you may want to leave out the --tags argument sometimes).

I personally use the following aliases to show unpushed commits:

# unpushed:  graph of everything excluding pushed/tag commits
# with boundary commits (see below for 'git g' alias)
git config alias.unpushed '!git g --not --remotes --tags'

# go:  _G_raph of _O_utgoing commits with boundary commits
# (see below for 'git gb' alias)
git config alias.go '!git gb @{u}..'

# g:  _G_raph of everything with boundary commits
git config alias.g '!git gb --all'

# gb:  _G_raph of current _B_ranch (or arguments) with boundary commits
git config '!git gbnb --boundary'

# gbnb:  _G_raph of current _B_ranch (or arguments) with _N_o _B_oundary commits
git config alias.gbnb 'log --graph --date-order --pretty=tformat:"%C(yellow)%h%Creset %C(magenta)%aE %ai%Creset %C(green bold)%d%Creset%n        %s"'

For simple repositories I use the git g alias as my primary method of exploring the commits. For complex repositories (dozens of branches), I generally use git gb to show specific branches or ranges of commits. When I want to see how git push will change the remote reference (my push.default is set to upstream), I use git go. When I want to see if there is anything anywhere in my local repository I haven't pushed (e.g., to see if I'll lose work if I delete the clone), I use git unpushed.

Need Your Help

Cannot connect to SQL Server express from SSMS

sql sql-server sql-server-2005 ssms

I have installed SQL Server Management Studio 2005. I can't find my server name when I click browse for more but i know that my server name will be the same as the user name as in the picture b...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.