0

I have 2 consecutive commits, e.g., fc07217 and cb7373b. I can view the changes made by the commit fc07217 via https://github.com/fmtlib/fmt/compare/cb7373b...fc07217. How can I obtain the changes brought in by both of these commits? I.e., the result of https://github.com/fmtlib/fmt/compare/795ed8a...fc07217, but without the explicit mention of the cb7373b's parent commit 795ed8a.

It might be useful to check the commits between some commit and the repository initial commit ec27d5d8 inclusive, because you can't specify the parent of the initial commit.

Relevant doc doesn't mention this possibility.

cppbest
  • 59
  • 8
  • You can use `^` after a commit to reference its direct parent. So [https://github.com/fmtlib/fmt/compare/cb7373b^...fc07217](https://github.com/fmtlib/fmt/compare/cb7373b^...fc07217) should work. Alternatively `~1` is the same thing as `^`. – Joachim Sauer Nov 03 '22 at 09:16
  • @JoachimSauer yes, it works when there is a parent commit, but it doesn't work for the initial commit case (`ec27d5d8`). – cppbest Nov 03 '22 at 09:35
  • 1
    The initial commit has no parent (by definition), so it can't work. Since commits in git don't store "changes" (they always store a complete snapshot) the question of "what's the diff of the initial commit" is non-sensical in the git world. The closest you could get to that is printing the entire content of the initial commit. In other words: if you want a diff to the "empty git repo", then just look at the last commit in your range. The whole content is the diff. – Joachim Sauer Nov 03 '22 at 09:40
  • @JoachimSauer in precise words, I need "what commits were made between `fc07217` and `ec27d5d8` inclusively and their contents" using GitHub UI, not the diff between `fc07217` and `ec27d5d8`. – cppbest Nov 03 '22 at 09:52
  • 2
    I don't think you can get that from the GitHub UI. But GitHub UI and API questions are about GitHub, not about Git. – torek Nov 03 '22 at 10:19
  • "diff with the initial commit inclusive" is simply : the content of the topmost commit, and consider that all the content has been added (`tree/`). If you *really* insist on viewing it as a diff in github, you can create a phony commit with an empty tree, and compare `...` – LeGEC Nov 03 '22 at 11:25
  • @LeGEC: Git repositories have an empty tree, so if you have a way to compare tree-to-tree with a GitHub URL (not sure if there is one, the commit-vs-commit one takes commits, but does it take tree object IDs?) you can use the [empty tree](https://stackoverflow.com/q/9765453/1256452). – torek Nov 03 '22 at 11:30
  • @torek it can take commits, tags, branches and even forks, but I've already tried `4b825dc642cb6eb9a060e54bf8d69288fbee4904` and it doesn't work. – cppbest Nov 03 '22 at 11:40
  • @LeGEC yeah, I think a dummy commit is the only way… – cppbest Nov 03 '22 at 11:42

0 Answers0