Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions bin/git-commits-since
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
#!/usr/bin/env bash

SINCE="last week"
test $# -ne 0 && SINCE=$*
echo "... commits since $SINCE" >&2
git log --pretty='%an - %s' --after="@{$SINCE}"
REF=""
SINCE=""

while [[ $# -gt 0 ]]; do
case "$1" in
-r|--ref)
if [[ -z "$2" ]]; then
echo "error: option $1 requires an argument" >&2
exit 1
fi
REF="$2"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's report an error if both $SINCE and $REF given

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

shift
shift
;;
*)
# non-flag args accumulation, e.g. "last " + "week" -> "last week"
SINCE="${SINCE:+$SINCE }$1"
shift
;;
esac
done

if [[ -n "$REF" && -n "$SINCE" ]]; then
echo "error: '--ref <ref>' and '<date>' are mutually exclusive" >&2
exit 1
fi

SINCE="${SINCE:-last week}"

if [[ -n "$REF" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if "$REF" exist before using it

Copy link
Contributor Author

@eskultety eskultety Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the actual ref or the variable itself? IOW do you want me to first verify that git can resolve the ref before I use it with the log command? If so, that was a deliberate decision, because the error from git is quite clear, IOW if invalidtag is used as a tag ref then it's a user error and we should let the command fail explicitly.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine.

git log --pretty='%h %an - %s' "$REF..HEAD"
else
git log --pretty='%h %an - %s' --after="@{$SINCE}"
fi
4 changes: 4 additions & 0 deletions etc/bash_completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ _git_contrib(){
COMPREPLY=($(compgen -W "$all" -- "$cur"))
}

_git_commits_since(){
__gitcomp "-r --ref"
}

_git_count(){
__gitcomp "--all"
}
Expand Down
5 changes: 5 additions & 0 deletions etc/git-extras-completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ _git-coauthor() {
':co-author-email[email address of co-author to add]:__gitex_author_emails'
}

_git-commits-since() {
_arguments \
'(-r --ref)'{-r,--ref}'[show commits since ref]'
}

_git-contrib() {
_arguments \
':author:__gitex_author_names'
Expand Down
2 changes: 2 additions & 0 deletions etc/git-extras.fish
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ function __fish_git_extra_coauthor_email
end
complete -c git -f -n '__fish_git_using_command coauthor; and __fish_git_arg_number 2' -a '(__fish_git_extra_coauthor_name)'
complete -c git -f -n '__fish_git_using_command coauthor; and __fish_git_arg_number 3' -a '(__fish_git_extra_coauthor_email)'
# commits-since
complete -c git -f -n '__fish_git_using_command commits-since' -s r -l ref -d 'show commits since ref'
# count
complete -c git -f -n '__fish_git_using_command count' -l all -d 'detailed commit count'
# create-branch
Expand Down
61 changes: 28 additions & 33 deletions man/git-commits-since.1
Original file line number Diff line number Diff line change
@@ -1,57 +1,52 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-COMMITS\-SINCE" "1" "October 2017" "" "Git Extras"
.
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GIT\-COMMITS\-SINCE" "1" "January 2026" "" "Git Extras"
.SH "NAME"
\fBgit\-commits\-since\fR \- Show commit logs since some date
.
.SH "SYNOPSIS"
\fBgit\-commits\-since\fR [<date>]
.
.TS
allbox;
\fBgit\-commits\-since\fR [\-r \-\-ref <ref>] [<date>]
.TE
.SH "DESCRIPTION"
List of commits since the given \fIdate\fR\.
.
List of commits since the given \fIdate\fR or \fIref\fR\.
.SH "OPTIONS"
<date>
.
.P
Show commits more recent than \fIdate\fR\. By default, the command shows the commit logs since "last week"\.
.
Show commits more recent than <date>\. By default, the command shows the commit logs since "last week"\.
.P
\-r, \-\-ref <ref>
.P
Show commits since the given ref (tag, branch, or commit)\. When specified, the command uses \fBref\.\.HEAD\fR instead of date\-based filtering\.
.SH "EXAMPLES"
It is really flexible and these are only 3 of the options, go ahead give it a try:
.
.IP "" 4
.
.nf

$ git commits\-since yesterday
\.\.\. commits since yesterday
nickl\- \- Merge branch upstream master\.
nickl\- \- Rebase bolshakov with master
TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks
TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop
nickl\- \- Fix #127 git\-ignore won\'t add duplicates\.
aa084d9 TweeKane \- Add global gitignore to git\-ignore output
515e94a TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks
5f86b54 TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop
7398d10 nickl\- \- Fix #127 git\-ignore won\'t add duplicates\.

$ git commits\-since 3 o clock pm
\.\.\. commits since 3 o clock pm
nickl\- \- Merge branch upstream master\.
aa084d9 TweeKane \- Add global gitignore to git\-ignore output

$ git commits\-since 2 hour ago
\.\.\. commits since 2 hour ago
nickl\- \- Merge branch upstream master\.
TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks
TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop
.
aa084d9 TweeKane \- Add global gitignore to git\-ignore output
515e94a TJ Holowaychuk \- Merge pull request #128 from nickl\-/git\-extras\-html\-hyperlinks
5f86b54 TJ Holowaychuk \- Merge pull request #129 from nickl\-/develop

$ git commits\-since \-\-ref 7\.4\.0
6ed2643 John Bachir \- ability to specify command when hitting enter (#1223)
b9bd309 John Bachir \- Improve `git\-repl` prompt (#1224)
6f4cf0c johnpyp \- feat: `delete\-branch` multiple unique branch names completions (#1221)
\|\.\|\.\|\.
215382b 罗泽轩 \- Bump version to 7\.5\.0\-dev (#1207)
.fi
.
.IP "" 0
.
.SH "AUTHOR"
Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR>
.
.SH "REPORTING BUGS"
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
.
.SH "SEE ALSO"
<\fIhttps://github\.com/tj/git\-extras\fR>
63 changes: 39 additions & 24 deletions man/git-commits-since.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 22 additions & 16 deletions man/git-commits-since.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,46 @@ git-commits-since(1) -- Show commit logs since some date

## SYNOPSIS

`git-commits-since` [&lt;date&gt;]
`git-commits-since` [-r|--ref &lt;ref&gt;] [&lt;date&gt;]

## DESCRIPTION

List of commits since the given _date_.
List of commits since the given _date_ or _ref_.

## OPTIONS

&lt;date&gt;

Show commits more recent than <date>. By default, the command shows the commit logs since "last week".
Show commits more recent than &lt;date&gt;. By default, the command shows the commit logs since "last week".

-r, --ref &lt;ref&gt;

Show commits since the given ref (tag, branch, or commit). When specified, the command uses `ref..HEAD` instead of date-based filtering.

## EXAMPLES

It is really flexible and these are only 3 of the options, go ahead give it a try:

$ git commits-since yesterday
... commits since yesterday
nickl- - Merge branch upstream master.
nickl- - Rebase bolshakov with master
TJ Holowaychuk - Merge pull request #128 from nickl-/git-extras-html-hyperlinks
TJ Holowaychuk - Merge pull request #129 from nickl-/develop
nickl- - Fix #127 git-ignore won't add duplicates.
aa084d9 TweeKane - Add global gitignore to git-ignore output
515e94a TJ Holowaychuk - Merge pull request #128 from nickl-/git-extras-html-hyperlinks
5f86b54 TJ Holowaychuk - Merge pull request #129 from nickl-/develop
7398d10 nickl- - Fix #127 git-ignore won't add duplicates.

$ git commits-since 3 o clock pm
... commits since 3 o clock pm
nickl- - Merge branch upstream master.
aa084d9 TweeKane - Add global gitignore to git-ignore output

$ git commits-since 2 hour ago
... commits since 2 hour ago
nickl- - Merge branch upstream master.
TJ Holowaychuk - Merge pull request #128 from nickl-/git-extras-html-hyperlinks
TJ Holowaychuk - Merge pull request #129 from nickl-/develop

aa084d9 TweeKane - Add global gitignore to git-ignore output
515e94a TJ Holowaychuk - Merge pull request #128 from nickl-/git-extras-html-hyperlinks
5f86b54 TJ Holowaychuk - Merge pull request #129 from nickl-/develop

$ git commits-since --ref 7.4.0
6ed2643 John Bachir - ability to specify command when hitting enter (#1223)
b9bd309 John Bachir - Improve `git-repl` prompt (#1224)
6f4cf0c johnpyp - feat: `delete-branch` multiple unique branch names completions (#1221)
...
215382b 罗泽轩 - Bump version to 7.5.0-dev (#1207)

## AUTHOR

Expand Down
Loading