Skip to content

Commit 6cbb005

Browse files
committed
docs(contributing): Add Git history and PR workflow guidelines
Provides clear instructions for maintaining a linear commit history and rebasing feature branches.
1 parent 34feeaa commit 6cbb005

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,37 @@ Issues are also welcome, [failing tests](#writing-tests) are even more welcome.
2121
on how to improve the documentation and please include documentation updates
2222
with your PR.
2323

24+
### Git history & pull request updates
25+
26+
We prefer a **linear commit history**.
27+
28+
* Keep your branch **up to date by rebasing on `main`** (not by merging `main` into your branch).
29+
* Prefer **atomic commits**: each commit should represent one logical change and leave the repo in a working state.
30+
* **Don’t squash everything into one commit** by default.
31+
Squash is fine when it helps you *create atomic commits* (for example, folding “fix tests” into the commit that introduced the tests).
32+
33+
A typical workflow looks like:
34+
35+
```shell
36+
# update your local main
37+
git fetch origin
38+
git checkout main
39+
git pull --ff-only
40+
41+
# rebase your feature branch onto the latest main
42+
git checkout my-feature
43+
git rebase origin/main
44+
45+
# if your branch is already on GitHub, you'll likely need a force push after rebasing
46+
git push --force-with-lease
47+
```
48+
49+
If you need to reorganize commits (split/merge/reword) before opening the PR, use an interactive rebase:
50+
51+
```shell
52+
git rebase -i origin/main
53+
```
54+
2455
## How it works
2556

2657
See [how it works](https://gitversion.net/docs/learn/how-it-works) in GitVersion's documentation

0 commit comments

Comments
 (0)