• Elise@beehaw.org
    link
    fedilink
    arrow-up
    5
    ·
    8 months ago

    I’m relatively new to git and rebase looks like a mess to me? Like it appears to be making duplicate commits and destroys the proper history?

    If you use rebase to get a more readable history, isn’t the issue the tool you use to view the history?

    I guess I have to try it out a few times to get it.

    • Ephera@lemmy.ml
      link
      fedilink
      arrow-up
      4
      ·
      8 months ago

      What you probably mean by duplicate commits is that it assigns new commit IDs to commits that have been rebased. If you had already pushed those commits, then git status will tell you that the remote branch and your local branch have diverged by as many commits as you rebased.

      Well, and what is the “proper history”? If your answer is “chronological”, then why so?
      For the rare times that it matters when exactly a commit was created, they’ve got a timestamp. But otherwise, the “proper history” is whatever you make the proper history. What matters is that the commits can be applied one after another, which a rebase ensures.

      When you’re working on a branch and you continuously rebase on the branch you want to eventually merge to, then the merged history will look as if you had checked out the target branch and just made your commits really quickly without anyone else committing anything in between.
      And whether you’ve done your commits really quickly or over the course of weeks, that really shouldn’t matter.

      What is really cool about (supposedly) making commits really quickly is that your history becomes linear and it tells a comprehensible story. It won’t be all kinds of unrelated changes mixed randomly chronologically, but rather related commits following one another.
      And of course, you also lose the merge-commits, which convey no valuable information of their own.