9

Assume the following history of commits, each commit is also a branch.

M - A - B
 \
  C

I then rebase B on top of C. I will now have

M - A
 \
  C - A' - B'

My question, is that given commit A, can I "discover" A'? Or given A', can I "discover" A?

To be more specific, I am given a commit hash XYZ, can I get all the commit hashes of all other commits who are the "rebased versions" of it?

lorg
  • 1,160
  • 1
  • 10
  • 27
  • 4
    [This question](https://stackoverflow.com/q/2922652/10871900) might be similar/helpful. You could e.g. search for the same commit message and (possibly) compare the changes, afterwards. But there is definetely no direct way to do what you want. – dan1st Feb 22 '21 at 19:27
  • You'd still have `M - A - B` too – evolutionxbox Feb 22 '21 at 19:38
  • @chepner Not with a rebase, (at least not without squash). A' will be created. – Madara's Ghost Feb 22 '21 at 19:52
  • @chepner I just reproduced the situation about and when rebasing B on C it create commit A with different commit ID after C therefore its A’. – Raz Luvaton Feb 22 '21 at 19:55
  • Never mind. I'm not sure what I was thinking of. (Cherry-picking, maybe?) – chepner Feb 22 '21 at 19:56
  • 1
    What is the search space? (All branches in repo, a specific branch, reflog, etc?) – TTT Feb 22 '21 at 22:06
  • @TTT All the branches in the repo – lorg Feb 23 '21 at 04:34
  • When you say "each commit is also a branch", do you mean that `A` is a branch with its own ref? How then is `A'` also a branch? This is relevant because if you are somehow (e.g. via custom script) all branch refs that are parents of the rebased branch, it should be possible to use the reflog to get what you want. Otherwise, there is no explicit connection between rebased commits, and you'd have to use implicit connections such as identical commit message, or something more complicated, such as comparing the parents of rebased branch tips map commits from before and after each rebase. – Inigo May 21 '21 at 15:44

0 Answers0