top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Somewhat quiet commit output in Git

0 votes
27 views

If I run "git commit", Git will output a lot of detailed information about the commit:

$ git commit -m 'Daily update.'
[master bb56ea6] Daily update.
1477 files changed, 183898 insertions(+), 8 deletions(-)
rewrite GTD/Email.ods (72%)
create mode 120000 [etc.]
$

If I run "git commit -q", Git will output nothing:

$ git commit -m 'Daily update.'
$

Is there an option to get "git commit" to output just the first line,
giving the commit hash, like this:

$ git commit -m 'Daily update.'
[master bb56ea6] Daily update.
$

posted May 15, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

2 Answers

0 votes

Cheat?
git commit -m 'Daily commit' | head -n 1

answer May 16, 2013 by anonymous
0 votes

I would do

git commit -q -m 'Daily commit' && git rev-parse HEAD

.
It's two calls, but the second one specifically designed to get the latest commit ID.

A possible downside is that if the repository is shared in some way (say, it's on a networked share) then there's a possible race between these adjacent calls to the git binary -- another developer is able
to update the HEAD (or a branch it points to) in the meantime.

answer May 16, 2013 by anonymous
Similar Questions
+2 votes

When does git shows message "nothing added to commit but untracked files present " ?

+2 votes

Could somebody tell me how to make git rebase -i show diff of squashed commits (for example), like git commit -v does it?

0 votes

There are shorthands for going back from HEAD, but not for the initial commit, AFAICT.

I often want to do this when rebasing, and have come to tagging the initial commit in my repos with INITIAL.

Is there a better syntax I'm missing?


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...