Incoming commits across all branches can be shown with the following approach.
The command git fetch-diff
becomes available by adding an executable called git-fetch-diff
to your PATH, containing:
#!/bin/bash
set -e
# get hashes before fetch
old_hashes=$(git log --all --no-color --pretty=format:"%H")
# perform the fetch
git fetch
# get hashes after fetch
new_hashes=$(git log --all --no-color --pretty=format:"%H")
# get the difference
added_hashes=$(comm -1 -3 <(echo "$old_hashes") <(echo "$new_hashes"))
# print added hashes
[ ! -z "$added_hashes" ] && echo "$added_hashes" | git log --stdin --no-walk --oneline
Commit hashes are compared before and after the fetch. The difference is piped back to git log
for pretty printing. The appearance of the printed log can be further tuned to your liking with arguments such as --pretty=<format>
and --graph
.
Note: You might want to cap how far git log
will go back in time depending on how much a bash variable can hold on your system, or for performance reasons. This can be done by adding the argument --max-count=<count>
.
hg incoming
andhg outgoing
actually do. The nearest Git equivalent I found is the--dry-run
option. Justgit pull --dry-run
and you'll see a list of all the things that need to happen. – Pull