Skip to content

Commit d58f5ac

Browse files
Update merge_conflicts.md
1 parent 636457f commit d58f5ac

1 file changed

Lines changed: 8 additions & 27 deletions

File tree

book/workflows/git/merge_conflicts.md

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,20 @@ Merge conflicts arise when people on separate branches modify the same parts of
33

44
![Visualisation of a merge conflict](https://files.mude.citg.tudelft.nl/mconflict1.png)
55

6-
Let us create a merge conflict ourselves:
7-
8-
We will start by making a new branch `conflicting-instructions` on GitHub. We will edit the `README.md` file on the last line
9-
10-
```
11-
...
12-
13-
And now I've edited this file on the `main`-branch. **I've added some text to this line now from the branch `conflicting-instructions`**
14-
```
15-
16-
![Creating a pull request](https://files.mude.citg.tudelft.nl/mconflict2.png)
17-
18-
Next, we will return to the `main` branch on GitHub. We will edit the same line of the markdown file with some other text:
19-
20-
```
21-
...
22-
23-
And now I've edited this file on the `main`-branch. **I add some text to the same line but now on `main`, will this give me a conflict?**
24-
```
25-
26-
Finally, we will attempt to merge the `main` branch into the `conflicting-instructions` branch using the pull request interface on GitHub. This will result in a merge conflict, as seen in the figure below, because we modified the same parts of the file.
6+
Git and GitHub assist you in solving these conflicts, as seen in the figure below:
277

288
![Merge conflict](https://files.mude.citg.tudelft.nl/mconflict3.png)
299

30-
The changes on the current branch are preceded by `<<<<<<< HEAD`, while the changes from the `main` branch are preceded by `=======` and followed by `>>>>>>> main`. To fix this conflict, we need to open the file in the GitHub editor and resolve the conflict by keeping the desired changes and removing the unnecessary parts. Once done, we can commit the resolved changes directly from the GitHub interface. Note that the current branch is now in a "MERGING" state. We have decided to take the best out of the two branches and merge their changes.
31-
32-
![Resolving conflict](https://files.mude.citg.tudelft.nl/mconflict4.png)
33-
![Completing the merge](https://files.mude.citg.tudelft.nl/mconflict5.png)
10+
In this situatie, it is attempted to merge main in a conflicting branch. The conflicting lines on the main branches are preceded by `<<<<<<< main`, while the changes from the conflicted `main` branch are preceded by `=======` and followed by `>>>>>>> conflicting-instructions`. To fix this conflict, we need to open the file in an editor (either on GitHub or locally on your computer) and resolve the conflict by keeping the desired changes and removing the unnecessary parts. Once done, we can commit the resolved changes . Note that the current branch is now in a "MERGING" state. We have decided to take the best out of the two branches and merge their changes.
3411

35-
### Why Merge into the conflicting branch first?
12+
## Why Merge into the conflicting branch first?
3613

3714
Merging into the conflicting branch first allows you to resolve conflicts in a controlled environment. Here are some reasons why this approach is beneficial:
3815

3916
- By resolving conflicts in the feature or conflicting branch, you isolate the changes and ensure that the main branch remains stable and conflict-free.
4017
- In case of coding, you can thoroughly test the merged changes in the conflicting branch before integrating them into the main branch, reducing the risk of introducing bugs.
41-
- Keeping the main branch clean and conflict-free simplifies the integration process and makes it easier for other team members to continue their work without interruptions.
18+
- Keeping the main branch clean and conflict-free simplifies the integration process and makes it easier for other team members to continue their work without interruptions.
19+
20+
## Why notebooks causes conflicts all the time
21+
22+
Yeah, this is really annoying. The JSON structure of a notebook causes the issue, as explained [here](../../version_control/notebooks.ipynb).

0 commit comments

Comments
 (0)