From 549f9ae8227ee6e993912107d8bde70fa05059d7 Mon Sep 17 00:00:00 2001 From: Vishal Anarase Date: Mon, 18 Aug 2025 13:44:41 +0530 Subject: [PATCH] docs: update git workflow documentation Signed-off-by: Vishal Anarase --- .../content/en/docs/community/contributing.md | 2 + website/content/en/docs/dev/git.md | 56 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 website/content/en/docs/dev/git.md diff --git a/website/content/en/docs/community/contributing.md b/website/content/en/docs/community/contributing.md index c6b8f4759c3..cfd74073395 100644 --- a/website/content/en/docs/community/contributing.md +++ b/website/content/en/docs/community/contributing.md @@ -55,6 +55,8 @@ It is highly suggested to add [tests](../../dev/testing/) for every non-trivial A test can be implemented as a unit test rather than an integration test when it is possible, to avoid slowing the integration test CI. +For tips on squashing commits and rebasing before submitting your pull request, see [Git Tips](../dev/git.md). + ### Merging pull requests [Committers](../governance) can merge pull requests. diff --git a/website/content/en/docs/dev/git.md b/website/content/en/docs/dev/git.md new file mode 100644 index 00000000000..f3443ee2702 --- /dev/null +++ b/website/content/en/docs/dev/git.md @@ -0,0 +1,56 @@ +--- +title: Git tips +weight: 30 +--- + +## Squashing Commits + +To combine multiple commits into one (recommended unless your PR covers multiple topics): + +```bash +# Adjust the number based on how many commits you want to squash +git rebase -i HEAD~3 +``` + +In the interactive editor that appears: +1. Keep the first commit as `pick` +2. Change subsequent commits from `pick` to `fixup` (short form`f`). You may also choose `squash` (`s`), however, `fixup` is recommended to keep the commit message clean. +3. 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: + +```bash +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: + +```bash +git rebase --abort # Cancel the rebase and return to original state +git status # Check current state +``` + +For merge conflicts during rebase: +1. Resolve the conflicts in the files +2. `git add` the resolved files +3. `git rebase --continue`