You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For more information, see [Git Branching - Basic Branching and Merging](https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging#_basic_merge_conflicts), [Advanced Merging](https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging), or ask in the `#sig-docs` Slack channel for help.
162
+
{{< /note >}}
163
+
164
+
If another contributor commits changes to the same file in another PR, it can create a merge conflict. You must resolve all merge conflicts in your PR.
For more information, see [Git Tools - Rewriting History](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History), or ask in the `#sig-docs` Slack channel for help.
228
+
{{< /note >}}
229
+
230
+
If your PR has multiple commits, you must squash them into a single commit before merging your PR. You can check the number of commits on your PR's **Commits** tab or by running the `git log`command locally.
231
+
232
+
{{< note >}}
233
+
This topic assumes `vim` as the command line text editor.
234
+
{{< /note >}}
235
+
236
+
1. Start an interactive rebase:
237
+
238
+
```bash
239
+
git rebase -i HEAD~<number_of_commits_in_branch>
240
+
```
241
+
242
+
Squashing commits is a form of rebasing. The `-i` switch tells git you want to rebase interactively. `HEAD~<number_of_commits_in_branch` indicates how many commits to look at for the rebase.
243
+
244
+
Output is similar to:
245
+
246
+
```bash
247
+
pick d875112ca Original commit
248
+
pick 4fa167b80 Address feedback 1
249
+
pick 7d54e15ee Address feedback 2
250
+
251
+
# Rebase 3d18sf680..7d54e15ee onto 3d183f680 (3 commands)
252
+
253
+
...
254
+
255
+
# These lines can be re-ordered; they are executed from top to bottom.
256
+
```
257
+
258
+
The first section of the output lists the commits in the rebase. The second section lists the options for each commit. Changing the word `pick` changes the status of the commit once the rebase is complete.
259
+
260
+
For the purposes of rebasing, focus on `squash` and `pick`.
261
+
262
+
{{< note >}}
263
+
For more information, see [Interactive Mode](https://git-scm.com/docs/git-rebase#_interactive_mode).
264
+
{{< /note >}}
265
+
266
+
2. Start editing the file.
267
+
268
+
Change the original text:
269
+
270
+
```bash
271
+
pick d875112ca Original commit
272
+
pick 4fa167b80 Address feedback 1
273
+
pick 7d54e15ee Address feedback 2
274
+
```
275
+
276
+
To:
277
+
278
+
```bash
279
+
pick d875112ca Original commit
280
+
squash 4fa167b80 Address feedback 1
281
+
squash 7d54e15ee Address feedback 2
282
+
```
283
+
284
+
This squashes commits `4fa167b80 Address feedback 1` and `7d54e15ee Address feedback 2` into `d875112ca Original commit`, leaving only `d875112ca Original commit` as a part of the timeline.
0 commit comments