Merging¶
git rebase¶
Flatten commits
git rebase -i HEAD~4where 4 is the number of commits- In the text editor, have the
pickchanged tosquashorsfor commits you don't want
git merge vs git rebase¶
- like
revertvsreset - Golden rule of rebasing: only rebase private branches
- Merge will create a new commit
- rebase will just move all the branch's new commits to the end of master's HEAD
-
git rebase -iis very useful for cleaning up private branches -
how to use the merge tool
git mergetool
Taking all their/our changes¶
- if you're already in a conflict state
git checkout --theirs path/to/filegit checkout --ours path/to/file
- pulling theirs:
git pull -X theirs
Last update:
2023-04-24