3
dUcKtYpEd
77d

Does anyone or has anyone struggled with Understanding get rebase ? I just can’t grasp everything it does in practice. I’m theory it makes sense but when someone tells me to debase off something to make something happen, I’m lost

Comments
  • 1
    Rebase is pretty easy:

    git checkout some-branch you want to rebase (b1)
    git rebase {branch you want to rebase} (b2)

    What it's going to do:
    - determine the point where your branch diverged from the target branch
    - move all commits to the common point into a stack (or rather, fill a commit-tree, but that's a detail)
    - pull all commits from the target branch into your current branch
    - pop the first commit from the "stack" of commits you made
    - check for conflict
    - continue (no conflict) or wait for git rebase --continue (or git rebase --skip)
    -- pop the next commit, rinse repeat conflict checks until out of commits you've created

    Quality of life tips:
    - Always flatten your commits before rebasing (git reset --soft {commit hash of first unique commit in your branch} && git commit -m "collapsed commit") (this ensures you only have to perform 1 conflict resolution)
    - Alternately, use git rebase -i and set squash on all but one of your commits
  • 1
  • 1
    @SortOfTested ok thats a nice explanation. I tried squashing the last two commits and then doing a rebase. It makes some sense to me. I guess the concept just needs to sit with me some and be done a few more times for me to fully grasp. Ive honestly avoided using it for 6 years now and its embarrassing when asked to do a rebase cause im like shit no ones ever demanded me to do one.
  • 0
    @WildOrangutan what in the world man tis is a cool tool
Add Comment