WEB-783: Add detailed commit squashing instructions to CONTRIBUTING.md (#3219)
WEB-783: Add detailed commit squashing instructions to CONTRIBUTING.md
This commit is contained in:
+32
-9
@@ -135,13 +135,36 @@ We maintain a linear, meaningful git history.
|
|||||||
- ❌ **Bad History:** `init`, `wip`, `typo`, `fix`, `fix again`
|
- ❌ **Bad History:** `init`, `wip`, `typo`, `fix`, `fix again`
|
||||||
- ✅ **Good History:** `WEB-123: Implement client search functionality`
|
- ✅ **Good History:** `WEB-123: Implement client search functionality`
|
||||||
|
|
||||||
**How to Squash:**
|
**How to Squash (Step-by-Step Example):**
|
||||||
|
|
||||||
```bash
|
1. **Start Interactive Rebase:** Run the following command (replace `2` with the number of commits you want to combine):
|
||||||
git rebase -i HEAD~N # Replace N with the number of commits
|
|
||||||
# Mark the first commit as 'pick' and subsequent commits as 'squash'
|
```bash
|
||||||
git push --force-with-lease
|
git rebase -i HEAD~2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
2. **Edit the Rebase File:** An editor will open listing your recent commits. It will look like this:
|
||||||
|
|
||||||
|
```text
|
||||||
|
pick a1b2c3d Message of the older commit
|
||||||
|
pick e4f5g6h Message of the newer commit
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Squash the Commits:** Change `pick` to `squash` (or `s`) for all commits except the first one:
|
||||||
|
|
||||||
|
```text
|
||||||
|
pick a1b2c3d Message of the older commit
|
||||||
|
s e4f5g6h Message of the newer commit
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Save and Close:** Save the file and close the editor.
|
||||||
|
|
||||||
|
5. **Finalize Message:** A new editor window will appear. Combine or edit the commit messages into a single, meaningful title (e.g., `WEB-123: Feature description`). Save and close.
|
||||||
|
|
||||||
|
6. **Force Push:** Send the changes to your remote repository.
|
||||||
|
```bash
|
||||||
|
git push origin branch-name --force-with-lease
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -225,9 +248,9 @@ git push --set-upstream origin branch-name
|
|||||||
|
|
||||||
- If any of the squashed commits have already been pushed to your remote repository, you need to do a force push.
|
- If any of the squashed commits have already been pushed to your remote repository, you need to do a force push.
|
||||||
|
|
||||||
```
|
```bash
|
||||||
git push origin remote-branch-name --force
|
git push origin branch-name --force-with-lease
|
||||||
```
|
```
|
||||||
|
|
||||||
- Follow the Pull request template and submit a pull request with a motive for your change and the method you used to achieve it to be merged with the `dev` branch.
|
- Follow the Pull request template and submit a pull request with a motive for your change and the method you used to achieve it to be merged with the `dev` branch.
|
||||||
- If possible, please submit the pull request along with tests.
|
- If possible, please submit the pull request along with tests.
|
||||||
|
|||||||
Reference in New Issue
Block a user