File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
website/content/en/docs/dev Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : Git Workflow - Squashing Commits and Rebasing
3+ weight : 30
4+ ---
5+
6+ ## Git Workflow: Squashing Commits and Rebasing
7+
8+ ### Squashing Commits
9+
10+ To combine multiple commits into one (recommended before submitting PRs):
11+
12+ ``` bash
13+ # Adjust the number based on how many commits you want to squash
14+ git rebase -i HEAD~3
15+ ```
16+
17+ In the interactive editor that appears:
18+ 1 . Keep the first commit as ` pick `
19+ 2 . Change subsequent commits from ` pick ` to ` squash ` or ` fixup ` (short form ` s ` or ` f ` )
20+ 3 . Save and close the editor to proceed
21+
22+ Example:
23+ ```
24+ pick aaaaaaa First commit message
25+ pick bbbbbbb Second commit message
26+ pick ccccccc Fix typo
27+ ```
28+
29+ To:
30+ ```
31+ pick aaaaaaa First commit message
32+ f bbbbbbb Second commit message
33+ f ccccccc Fix typo
34+ ```
35+
36+ ### Rebasing onto Upstream Master
37+
38+ To update your branch with the latest changes from upstream:
39+
40+ ``` bash
41+ git remote add upstream https://github.com/lima-vm/lima.git # Only needed once
42+ git fetch upstream
43+ git rebase upstream/master
44+ ```
45+
46+ ### Troubleshooting
47+
48+ If you encounter issues during rebase:
49+
50+ ``` bash
51+ git rebase --abort # Cancel the rebase and return to original state
52+ git status # Check current state
53+ ```
54+
55+ For merge conflicts during rebase:
56+ 1 . Resolve the conflicts in the files
57+ 2 . ` git add ` the resolved files
58+ 3 . ` git rebase --continue `
You can’t perform that action at this time.
0 commit comments