Source: https://www.atlassian.com/git/tutorials/merging-vs-rebasing
Both of these commands integrate one branch into another branch.
git checkout myBranch
git merge master
OR
git merge feature master
Pros: non destructive
Cons: every merge will be its own commit.
git checkout feature
git rebase master
Pros: cleaner project history (linear history)
Cons: more dangerous, and lose context.
Interactive rebasing:
git rebase -i
fixup
: fixes a problem in the previous commit.
squash
: merges commits.
Golden rule of rebasing: never use it on public branches!!
To push the rebased master branch to a remote repository, do git push --force
git rebase -i HEAD~3
: only rewriting the last three commits