Skip to content

Commit 549f9ae

Browse files
committed
docs: update git workflow documentation
Signed-off-by: Vishal Anarase <iamvishalanarase@gmail.com>
1 parent c316067 commit 549f9ae

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

website/content/en/docs/community/contributing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ It is highly suggested to add [tests](../../dev/testing/) for every non-trivial
5555
A test can be implemented as a unit test rather than an integration test when it is possible,
5656
to avoid slowing the integration test CI.
5757

58+
For tips on squashing commits and rebasing before submitting your pull request, see [Git Tips](../dev/git.md).
59+
5860
### Merging pull requests
5961

6062
[Committers](../governance) can merge pull requests.

website/content/en/docs/dev/git.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Git tips
3+
weight: 30
4+
---
5+
6+
## Squashing Commits
7+
8+
To combine multiple commits into one (recommended unless your PR covers multiple topics):
9+
10+
```bash
11+
# Adjust the number based on how many commits you want to squash
12+
git rebase -i HEAD~3
13+
```
14+
15+
In the interactive editor that appears:
16+
1. Keep the first commit as `pick`
17+
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.
18+
3. Save and close the editor to proceed
19+
20+
Example:
21+
```
22+
pick aaaaaaa First commit message
23+
pick bbbbbbb Second commit message
24+
pick ccccccc Fix typo
25+
```
26+
27+
To:
28+
```
29+
pick aaaaaaa First commit message
30+
f bbbbbbb Second commit message
31+
f ccccccc Fix typo
32+
```
33+
34+
## Rebasing onto Upstream Master
35+
36+
To update your branch with the latest changes from upstream:
37+
38+
```bash
39+
git remote add upstream https://github.com/lima-vm/lima.git # Only needed once
40+
git fetch upstream
41+
git rebase upstream/master
42+
```
43+
44+
## Troubleshooting
45+
46+
If you encounter issues during rebase:
47+
48+
```bash
49+
git rebase --abort # Cancel the rebase and return to original state
50+
git status # Check current state
51+
```
52+
53+
For merge conflicts during rebase:
54+
1. Resolve the conflicts in the files
55+
2. `git add` the resolved files
56+
3. `git rebase --continue`

0 commit comments

Comments
 (0)