Keeping Feature Branches Up To Date With Rebasing | by

Поделиться
HTML-код
  • Опубликовано: 29 сен 2024
  • ► Java/Spring courses & guides
    www.marcobehle...
    ► Newsletter
    bit.ly/2K0Ao4F
    ► RUclips sub
    bit.ly/2lVExgm
    Usually when you work on a feature branch, other team members add other things to, say, the master branch. You then need to get these changes into your feature branch, to keep it up to do. You could use merges for that, which somewhat litter your Git history, or use rebases, which might be a bit trickier to use, but keep your history clean. Learn how to do that in this episode.

Комментарии • 57

  • @aleksandrkravtsov8727
    @aleksandrkravtsov8727 3 года назад +16

    haha, man it is a bit scary when you stay with freezing smile on a face while screen is fading out :D great lessons. thank you

    • @aaronsan-yuo9516
      @aaronsan-yuo9516 2 года назад

      😅😅😅 had the exact thought man! Great video though:)

  • @yevheniibondarenko2398
    @yevheniibondarenko2398 Год назад

    Thanks!

  • @LucasRodrigues-ye3qx
    @LucasRodrigues-ye3qx 4 года назад +1

    this video was very helpful, thanks!

  • @cryp0g00n4
    @cryp0g00n4 2 года назад +1

    Wouldn't it make more sense for feature 2 & 3 to be on top of the reset commit and bugfix the last commit in the history? Feature 2 & 3 were created before bug fix and therefore "in time" older than the bugfix commit. Alternatively you could cherrypick bug fix on top of feature branch and then when ready rebase it all on top of the reset commit. Food for thought.

  • @pro100bega
    @pro100bega 4 года назад

    Great explanation, thank you!

  • @chezhiyanspartan5080
    @chezhiyanspartan5080 2 года назад

    on point!

  • @bhaaratsharma6023
    @bhaaratsharma6023 4 года назад

    Thanks man.

  • @paurushgargtube
    @paurushgargtube 2 года назад

    Which IDE u r using?

  • @hosmanadam
    @hosmanadam 3 года назад +2

    IMHO, this is often way too painful to be worth the nicer-looking log. Having to do one merge is annoying enough, but having to do 20? No thank you :D

    • @cryp0g00n4
      @cryp0g00n4 2 года назад

      I noticed the same. I went through the trouble as an exercise... and i spent an additional 4 hours to complete the rebase with all options. I learned a ton about history rewriting and git internals but recognized that it is not sustainable to be a git history maintainer ... just stick to the simple flows. Rebase once your feature is complete onto master and merge into feature... that way you have at least one good line of development while your forks is where you test out your ideas.

  • @LeandroCavalcanteLeandrw
    @LeandroCavalcanteLeandrw 4 года назад +1

    How to deal with big rebases?
    Sometimes I try `git pull --rebase` and I stuck with > 50 commmits to rebase.
    I do `git rebase --skip` for others commits, but I'm not sure if I'm doing right.

    • @sanmatrix2
      @sanmatrix2 4 года назад

      do frequent commits. There is no hard and fast rule for making commits but so long as you add a new file (my style) make a commit. then push the commit so you are doing rebases in incremental steps. Avoid making huge changes and then making commits as during a rebase, there might be multiple conflicts with your branch and the master's branch (or main branch). Hope this tip helps!

  • @bartdart3315
    @bartdart3315 2 года назад +1

    dude, i like your vids, but I have always avoided rebasing. If, it is as complicated in your contrived example, then in the "real world" it would be bamboozling!!! I know its the correct way...but no way! I agree with Adam Hosman below.

  • @bosypuspus
    @bosypuspus 3 года назад +3

    squash commit feature 2 and feature 3, you will only have to resolve conflicts once.

  • @askargarifullin1961
    @askargarifullin1961 2 года назад +7

    This tutorial is so eloquent and much more explanatory than other youtube videos on rebasing. Thank you!

  • @MasonStormSunny
    @MasonStormSunny 3 года назад +7

    If your remote is protected against push --force and push --force-with-lease you can do it as follows:
    git checkout feature-branch
    git rebase master
    git push origin --delete feature-branch
    git push origin feature-branch

    • @questionyourbeliefs
      @questionyourbeliefs Год назад +1

      Doesn't this destroy the pull request?

    • @MasonStormSunny
      @MasonStormSunny Год назад

      @@questionyourbeliefs Even if it does as I am not sure - what is the problem with a new PR creation and discarding the old one?

  • @ziat1988
    @ziat1988 11 месяцев назад

    I don't get why avoid rebase when working with other developer? If I'm the only one work with feature A and other dev work with feature B , I still can rebase ?

  • @gogobram
    @gogobram 3 года назад +2

    Pfff ... "use git" they say. It will be easier. :) As much as I would love to like git. Sometimes it's really a terribly complex monster. It's a minefield. I had the exact situation which you showed in your video today. I did a rebase, I wanted to push, and intellij told me there was another conflict. Surprised I clicked the "merge" button, and saw the strangest things. I agreed to accept the changes and then it told me I was running 100 commits ahead of the remote. I decided to throw my files away and to clone the repository over again. And I ran into the same thing. Until I found your video nothing seemed to explain what was happening here. Thank you very much for taking your time to create this video.

  • @persistent-s
    @persistent-s Год назад +1

    Thanks!

  • @christophec8589
    @christophec8589 6 лет назад +5

    Thanks Marco !
    Here each developper is working alone on its own feature branch (one task = one JIRA = one guy = one feature branch)
    So what you show is 100% useful to us and better than merging updated main develop branch onto a feature branch

  • @sloochik
    @sloochik 5 месяцев назад

    Very helpful video! Thank you for the explanation

  • @ВолодимирТрубін
    @ВолодимирТрубін Год назад +1

    Very clear and understandable explanation. Thank you a lot!!!

  • @karolbielen2090
    @karolbielen2090 4 года назад +3

    6:37 Actually, this is no longer true. For some time, force with lease is the default force push (at least in Intellij Community)

    • @gogobram
      @gogobram 3 года назад

      but you still need to do so using the terminal, right ?

    • @karolbielen2090
      @karolbielen2090 3 года назад +2

      @@gogobram, no, of course not. I mean that the force push that Intellij offers is the force with lease by defaut. Or, in other words, you no longer need terminal to push force with lease

  • @darshanprakash
    @darshanprakash 4 года назад +2

    Thank you so much, you just showed me what I was looking for.

  • @antonhub9636
    @antonhub9636 3 года назад +1

    Nice. This clarified my doubts 👌🏻

  • @juliaculakova8628
    @juliaculakova8628 3 года назад +1

    Thank you!!! So very helpful! I was struggling with the rebase for few days.

  • @amoghphadke4747
    @amoghphadke4747 5 лет назад +2

    great help ... I was wondering if you could show how to squash commits using intellij git

    • @MarcoBehler
      @MarcoBehler  5 лет назад +1

      I'll put it into my ever growing backlog :D

    • @theangrycoder4680
      @theangrycoder4680 2 года назад

      @@MarcoBehler Should not teach git rebase without squash. It is bs without squash. wtf wants to go through all those commits. fck me.

    • @moulayyoussefasakour769
      @moulayyoussefasakour769 2 года назад +1

      Open git log window > select the commits you want to squash > right click and you'll find squash command in the context menu.

  • @mkrzyzowski
    @mkrzyzowski 2 года назад

    Git Push window has [Push] button with arrow down. That arrow popup [Force push] button. Easy. :)

    • @mkrzyzowski
      @mkrzyzowski 2 года назад

      Thx for video, I was looking for the way to rebase as I migrated here from Sourcetree.

  • @paultorres6844
    @paultorres6844 2 года назад

    What is the equivalent of this on the command line?

  • @fbottone
    @fbottone 2 года назад

    @Marco do you have a video on what editor this is?

  • @minhan2198
    @minhan2198 2 года назад

    Hi Marco, as of today, is it still true that it's not possible to force push via intellij git when rebasing and instead having to run git push -f in the terminal?

    • @moulayyoussefasakour769
      @moulayyoussefasakour769 2 года назад

      Klik the right arrow next to the bleu button of the pop-up window (for a normall push) and you will find a second option for force push.

  • @goout88
    @goout88 2 года назад

    git push --force-with-lease

  • @cehson
    @cehson 4 года назад

    Awesome tutorial about rebasing, i needed this. Thanks allot !

  • @vemulasivanagasai5691
    @vemulasivanagasai5691 4 года назад

    Awesome ..this is what I was exactly looking for..

  • @MasonStormSunny
    @MasonStormSunny 3 года назад

    Thanks, nice description.

  • @alirahimi7425
    @alirahimi7425 2 года назад

    thank you for your great tips

  • @andhieji3
    @andhieji3 3 года назад

    so he try to fix his kitten.

  • @ttr738
    @ttr738 3 года назад

    Best explanation! Thankyou!

  • @sandeepm3528
    @sandeepm3528 3 года назад

    Very helpful thanks !!

  • @Greatfulone
    @Greatfulone 3 года назад

    Thank you.

  • @MohamedHelmys
    @MohamedHelmys 4 года назад

    what is your code editor u are using?

  • @chadlooker4657
    @chadlooker4657 4 года назад

    Well done

  • @TdmitriyV
    @TdmitriyV 5 лет назад

    Thanks a lot

  • @tarunsalecha6542
    @tarunsalecha6542 3 года назад

    Which ide is this?