2) Init Branch.
3) Commit "1", in Branch. .
4) Commit "2" in Master.
4) Commit "2" in Master.
5) Commit "3" in Branch.
Git Merge:
"Your repository’s commit history is a record of what actually happened."
git checkout mybranch
git merge master
Note in the above diagram, I have merge the master into branch.
Note that, the second commit is applied after the third commit in my branch, and a new merge commit is created.
git rebase master.
Here I have rebased mybranch onto master
Now here instead of using a merge commit, rebasing re-writes the project history by creating brand new commits for each commit in the original branch.
See that all the branch history is applied on top of master log history.
In general the way to get the best of both worlds is to rebase local changes you’ve made but haven’t shared yet before you push them in order to clean up your story, but never rebase anything you’ve pushed somewhere.
Note that, the second commit is applied after the third commit in my branch, and a new merge commit is created.
Git Rebase:
"The repository's commit history is the story of how your project was made."
git checkout mybranchgit rebase master.
Here I have rebased mybranch onto master
Now here instead of using a merge commit, rebasing re-writes the project history by creating brand new commits for each commit in the original branch.
See that all the branch history is applied on top of master log history.