Git - Can you do something with rebase that you cannot do merge?

Every time I tried rebase, I was involved in an endless cycle of unsolvable conflicts. Before conflict resolution x, a conflict arose, and then x conflict again, etc.

The fact is that (apparently) mergeor even cherry-pickprovide the same functionality that you could expect from rebase, right? If not, what utility rebase?

+4
source share
2 answers

rebaseoverwrites the story. Is this the way more mergeor cherry-pick- a very advanced tool that takes over (and can be dangerous as it overwrites the story ... be careful with git push -f). When rebaseused in a similar way merge, the process is quite distinctly different.

git fetch origin && git merge origin/master:

  • download changes from source
  • merging changes over the local branch
  • resolve conflicts and commit

git fetch origin && git rebase origin/master:

  • download changes from source
  • reset the local branch to a common point in the history (commit, which is used by both local and remote repositories)
  • fast forward
  • apply your commits on top of new commits one at a time
  • resolve conflicts and commit for each local change

rebase , , "" , ", ." , , , , "" .

, rebase - , . , , .. !

+4

rebase . :

  • master .
  • feature-branch
  • feature-branch
  • , feature-branch, rebase .
  • feature-branch, master.

    git checkout master
    git checkout feature-branch
    git commit -am "feature commit #1"
    git commit -am "feature commit #2"
    git commit -am "feature commit #3"
    git checkout master
    git commit -am "hot fix"
    git checkout feature-branch
    git rebase master
    git commit -am "i'm done"
    git checkout master
    git merge feature-branch
    

master git.

+2

Source: https://habr.com/ru/post/1613376/


All Articles