|
| 1 | +# Development Guidelines |
| 2 | + |
| 3 | +This document outlines the contribution and development practices to ensure a clean and maintainable Git history. |
| 4 | + |
| 5 | +## 1. Commit Sign-Off Requirement |
| 6 | + |
| 7 | +All commits must be **signed off** to certify that the contributor agrees to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). |
| 8 | +This is a legal statement indicating that you wrote the code or have the right to contribute it. |
| 9 | + |
| 10 | +### How to Sign Off a Commit |
| 11 | + |
| 12 | +When creating a commit, use the `-s` flag: |
| 13 | + |
| 14 | +```bash |
| 15 | +git commit -s -m "feat: add token validation logic" |
| 16 | +``` |
| 17 | + |
| 18 | +This will append a `Signed-off-by` line with your name and email address, matching the information in your Git configuration. |
| 19 | + |
| 20 | +Example: |
| 21 | + |
| 22 | +``` |
| 23 | +Signed-off-by: Jane Doe <[email protected]> |
| 24 | +``` |
| 25 | + |
| 26 | +If you forgot to sign off a commit, you can amend the last commit: |
| 27 | + |
| 28 | +```bash |
| 29 | +git commit --amend -s |
| 30 | +``` |
| 31 | + |
| 32 | +Or for multiple commits, you can rebase and add the sign-offs: |
| 33 | + |
| 34 | +```bash |
| 35 | +git rebase -i HEAD~N # replace N with number of commits to edit |
| 36 | +# Then mark each commit with 'edit' and sign off each one: |
| 37 | +git commit --amend -s |
| 38 | +git rebase --continue |
| 39 | +``` |
| 40 | + |
| 41 | +## 2. Linear Commit History: Rebase, Don’t Merge |
| 42 | + |
| 43 | +We follow a **linear commit history** to keep the Git log clean and easy to follow. This means **no merge commits** should be introduced. |
| 44 | + |
| 45 | +### Rebase Workflow |
| 46 | + |
| 47 | +1. Before pushing your branch, always rebase on the latest `main`: |
| 48 | + |
| 49 | + ```bash |
| 50 | + git fetch origin |
| 51 | + git rebase origin/main |
| 52 | + ``` |
| 53 | + |
| 54 | +2. If there are any conflicts, resolve them and continue the rebase: |
| 55 | + |
| 56 | + ```bash |
| 57 | + git status # See conflicted files |
| 58 | + # Edit and resolve conflicts |
| 59 | + git add <resolved-files> |
| 60 | + git rebase --continue |
| 61 | + ``` |
| 62 | + |
| 63 | +3. Force push your rebased branch to update your pull request: |
| 64 | + |
| 65 | + ```bash |
| 66 | + git push --force-with-lease |
| 67 | + ``` |
| 68 | + |
| 69 | +### Why No Merge Commits? |
| 70 | + |
| 71 | +- They clutter the history. |
| 72 | +- They make it harder to identify what changes were made. |
| 73 | +- They complicate tools that generate changelogs or audit logs. |
| 74 | + |
| 75 | +## 3. Additional Notes |
| 76 | + |
| 77 | +- Use clear, concise commit messages (preferably using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)). |
| 78 | +- Squash commits as needed before submission to keep the history clean. |
| 79 | +- Open a pull request only after your branch is up-to-date and rebased on `main`. |
0 commit comments