I can see revision number in svn by commands like svn info, but in git i can only see sha object names, is there any way to know how many revisions have been commited?
To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.
To find a git commit id (or hash), you can simply use the git log command. This would show you the commit history, listing the commits in chronological order, with the latest commit first.
If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .
git describe would be the closest way to get that kind of information, as suggested in this other SO question
[torvalds@g5 git]$ git describe parent
v1.0.4-14-g2414721
i.e. the current head of my "parent" branch is based on
v1.0.4
, but since it has a few commits on top of that, describe has added the number of additional commits ("14") and an abbreviated object name for the commit itself ("2414721
") at the end.
The number of additional commits is the number of commits which would be displayed by "
git log v1.0.4..parent
".
The hash suffix is "-g
"+ 7-char
abbreviation for the tip commit of parent (which was2414721b194453f058079d897d13c4e377f92dc6
).
Note that Git 2.22 (Q2 2019) amend the last sentence, since, while the minimum is 7-char, the unambiguous length can be longer.
The git describe
documentation now says:
The hash suffix is "-g" + unambiguous abbreviation for the tip commit of parent (which was
2414721b194453f058079d897d13c4e377f92dc6
).
See commit ffea024 (06 Apr 2019) by Philip Oakley (PhilipOakley
).
(Merged by Junio C Hamano -- gitster
-- in commit 18c3ae0, 25 Apr 2019)
Of course, you can always count your commits
git shortlog -s -n
135 Tom Preston-Werner
15 Jack Danger Canty
10 Chris Van Pelt
The
-s
option squashes all of the commit messages into the number of commits, and the-n
option sorts the list by number of commits.
This command could also be useful for
changelogs
, since you could easily dump all the changes each person has done.
There’s a few other neat options:-e
will append emails, and you can control columns widths with-w
.
Check out the manpage for more information.
With Git 2.33 (Q3 2021), you know more about git describe
exact output format:
See commit bfe35a6 (17 May 2021) by Anders Höckersten (ahockersten
).
(Merged by Junio C Hamano -- gitster
-- in commit d8c6dc2, 10 Jun 2021)
describe-doc
: clarify default length of abbreviationSigned-off-by: Anders Höckersten
Clarify the default length used for the abbreviated form used for commits in git describe.
The behavior was modified in Git 2.11.0, but the documentation was not updated to clarify the new behavior.
git describe
now includes in its man page:
Instead of using the default number of hexadecimal digits (which will vary according to the number of objects in the repository with a default of 7) of the abbreviated object name, use
<n>
digits, or as many digits as needed to form a unique object name.
git describe
now includes in its man page:
The hash suffix is "-g" + an unambigous abbreviation for the tip commit of parent (which was
2414721b194453f058079d897d13c4e377f92dc6
).
The length of the abbreviation scales as the repository grows, using the approximate number of objects in the repository and a bit of math around the birthday paradox, and defaults to a minimum of 7.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With