0

When I execute git show --summary I got the following details.

commit bef16f4aec08ac631733fd62e8829b808c38ea07
Author: Manu <manu@gmail.com>
Date:   Thu Aug 16 18:12:08 2018 +0530

    Update Jenkinsfile

In the above response Date is the latest committed date. Actually what I want is to get the branch creation date i.e the date-time which the branch is been created from the master.

Can anyone please help me on this

Alex Man
  • 4,746
  • 17
  • 93
  • 178
  • @Chris Actually what my goal is get only the date string....not the full summary – Alex Man Aug 16 '18 at 15:48
  • Your example shows summary output which led me (and likely others) to believe that was what you wanted. Combined with the duplicate, does [this](https://stackoverflow.com/a/3815007/354577) help? If not, please [edit] your question and clarify it. – ChrisGPT was on strike Aug 16 '18 at 17:07
  • @Chris I have edited my question. [this](https://stackoverflow.com/a/3815007/354577) does not help me to get the actual result – Alex Man Aug 16 '18 at 17:13
  • Sorry Alex, your updated question looks semantically the same as your previous one to me. Are you trying to get something like `Thu Aug 16 18:12:08 2018 +0530`, without any of the other accompanying data, and for the first commit on the branch? (Note that even talking about "branch creation date" is a bit tricky with Git.) If so, does the link I provided in my last comment (look at the `--format` part) help? – ChrisGPT was on strike Aug 16 '18 at 17:15
  • @Chris Actually I have created this branch at `Thu Aug 9 11:09:08 2018 +0530` from master but when I execute `git show --summary` or when I execute `git log -1 --format=%ci --date=local` its returning the last commited date which is `Thu Aug 16 18:12:08 2018 +0530` not the date of branch creation date which is `Thu Aug 9 11:09:08 2018 +0530` – Alex Man Aug 16 '18 at 17:21
  • Again, the "date at which a branch was created" isn't straightforward in Git. Branches don't really carry any data, they just point to commits. Did you try using `git merge-base`, as suggested in the accepted answer on the duplicate question? (Actually, that will probably give you the timestamp of the parent commit to the one you want...) What about the `git reflog show` option shown in another answer? – ChrisGPT was on strike Aug 16 '18 at 19:55

1 Answers1

1

Why don't you try reflog

git reflog --date=local --all

You can read more about it in git reflog documentation

Arghya Saha
  • 5,599
  • 4
  • 26
  • 48
  • Thanks for the reply when I want only the date. When I tried `git reflog --date=local --all` I got `bef16f4 refs/heads/release/rel_releasetest@{Thu Aug 16 20:21:33 2018}: clone: from https://github.com/manu/test-pro.git 5d0e59e refs/remotes/origin/HEAD@{Thu Aug 16 20:21:33 2018}: clone: from https://github.com/manu/test-pro.git ` – Alex Man Aug 16 '18 at 15:47