1

I amended a commit in a github repository (wrong version in a Changelog file) some days later after the commit was pushed. When I do a git log I see that the amended commit still has the date of the original commit as it should, but in github it shows the current date instead of the original commit date as git log does. Why is this ?

Juancho
  • 629
  • 7
  • 17
  • 4
    There's *date authored* and *date committed*, it's showing one of those. I forget which. Git itself should also reflect this – Timothy G. Jun 03 '21 at 16:48
  • @TimothyG., yeah I supposed that too, I was more wondering why github prefers to show the commit date instead of the authored date as doing that will mess up with the commits timeline. – Juancho Jun 03 '21 at 17:07
  • @phd your command is wrong, you are missing a "t" on `--format` – Juancho Jun 03 '21 at 17:08
  • Fixed, sorry: `git log --format=fuller` – phd Jun 03 '21 at 17:12

1 Answers1

2

Firstly, commits in git are immutable; you cannot in fact edit a commit. When you use commands such as commit --amend, cherry-pick, or rebase, what happens is that git creates a new commit, based on the original commit.

This new commit stores two sets of information:

  • The "author" name and e-mail address, and "date authored", copied from the original commit
  • The "committer" name and e-mail address, and "date committed", for the newly created commit

In fact, all commits have both sets of fields, it's just that they're generally the same, because a normal commit is "authored" and "committed" simultaneously.

What you're seeing is that "git log" on the command line is defaulting to show only the author information, and Github is defaulting to show the committer information. As far as I know, Github has no option to see both (despite its popularity, Github is actually quite a limited UI), but on the command line, you can see both at once with various formatting options, most simply:

git log --format=fuller
IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • thank you for your answer. I'm aware of what you say, my question was more on the lines of why github defaults to the committer information, as from the author PoV the commit timeline shown looks wrong. – Juancho Jun 03 '21 at 17:12
  • 2
    @Juancho Meh; "why" is generally a pretty meaningless question - even if your question somehow attracted the attention of a Github employee who was in the relevant sprint planning meeting or whatever when that code was written 15 years ago, I doubt they'd remember the exact reasoning applied. They had two to pick from, and they picked. ‍♂️ – IMSoP Jun 03 '21 at 17:14
  • @IMSoP: I'd say that *why* is a great *philosophical* question. It's just that answering philosophical questions has the same amount of practical utility as teats on a boar. – torek Jun 03 '21 at 22:07