Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions website/content/en/docs/community/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
56 changes: 56 additions & 0 deletions website/content/en/docs/dev/git.md
Original file line number Diff line number Diff line change
@@ -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`