Git tips
Squashing Commits
To combine multiple commits into one (recommended unless your PR covers multiple topics):
# Adjust the number based on how many commits you want to squash
git rebase -i HEAD~3
In the interactive editor that appears:
- Keep the first commit as
pick - Change subsequent commits from
picktofixup(short formf). You may also choosesquash(s), however,fixupis recommended to keep the commit message clean. - Save and close the editor to proceed
Example:
pick aaaaaaa First commit message
pick bbbbbbb Second commit message
pick ccccccc Fix typo
To:
pick aaaaaaa First commit message
f bbbbbbb Second commit message
f ccccccc Fix typo
Rebasing onto Upstream Master
To update your branch with the latest changes from upstream:
git remote add upstream https://github.com/lima-vm/lima.git # Only needed once
git fetch upstream
git rebase upstream/master
Troubleshooting
If you encounter issues during rebase:
git rebase --abort # Cancel the rebase and return to original state
git status # Check current state
For merge conflicts during rebase:
- Resolve the conflicts in the files
git addthe resolved filesgit rebase --continue