Difference between git pull --rebase, git rebase and git merge

Can anyone explain this by preserving even the remote repositories?

+6
source share
2 answers

git pull --rebase is the way you want to update your development branch - these branches are usually not published by others (except perhaps to take a look at it), so rewriting the story is not a problem and you really don't want to mergers, etc. in such a branch.

git merge merges; see the man page for details - comand has tons of options that would be too much to explain here.

git rebase does rebase, i.e. overwrites the history. It will execute your transactions to the extent that they deviate from another branch, temporarily delete them, apply the missing commits from the other branch, and then reapply your commits. git rebase also has an interactive mode in which you can delete / modify / squash certain commits.

Check out http://learn.github.com/p/rebasing.html for some interesting graphs of how dashboards work.

+7
source

git rebase allows git rebase to separate a branch from a blurry point and reconnect it to another branch. git merge instead simply merges changes from another branch in the current branch, without restarting the story.

If there are no conflicts, the result is identical between merge and rebase, but the story is different:

 (merge branch on master): master --A--B--C--E / branch --D (rebase branch onto master): master --A--B--C--D' 

In the first case, the merge creates a branch , which merges into master , which leads to the creation of the merge, E In the second case, D simply reboots to master , creating an entther commit, D' .

git pull --rebase will pull the changes from the remote computer and also reinstall your changes on top of it. It will literally record your changes that are not on the remote control and play them back from the last change that he just selected.

+6
source

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


All Articles