-
Notifications
You must be signed in to change notification settings - Fork 3
/
session-conflict.qmd
93 lines (70 loc) · 2.79 KB
/
session-conflict.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
title: "Introduction to Git and GitHub"
title-slide-attributes:
data-background-color: "#43464B"
subtitle: "Session - Conflicts!"
author: "Zoë Turner"
format:
revealjs:
theme: [default, nhsr-quarto.scss]
logo: https://raw.githubusercontent.com/nhs-r-community/assets/main/logo/nhsr-logo.svg
code-link: true
css: nhsr-quarto.scss
preview-links: true
execute:
echo: true
eval: false
embed-resources: true
---
## Conflicts!
Conflicts can happen when you merge a branch and can occur when working with others, or even yourself!
Let's create a conflict...
## Your Turn
1. `usethis::pr_init("author_change")`
2. Replace the author in the Quarto YAML with `author: Person A` and Render
3. `gert::git_commit_all("Added Person A as author")`
4. `usethis::pr_push()`
5. In GitHub create a pull request to `main` using `Merge pull request` and do the merge
::: {.callout-warning collapse="false" appearance="default" icon="true"}
## Not pulling from `main`
We'll miss the `pr_finish()` part because this function reduces the possibility of conflict as it `pulls` changes made on `main`
:::
## Together we will...
... create another branch in RStudio, not {usethis}, as we miss the steps that reduce conflicts:
1. Go to the `main` branch using the RStudio Git pane
2. Create a branch in that pane using the button next to `person-b`
3. Replace the author in the Quarto YAML with `author: Person B` and Render
4. Tick the box next to the file and commit using the Git pane in RStudio
5. Push the changes using RStudio Git pane (the button is not greyed out)
6. In GitHub create a pull request to `main` using `Merge pull request` and do the merge
## Conflict in GitHub!
![](img/github_conflict.PNG){fig-alt="Screenshot of GitHub merge conflict with the Resolve Conflict grey section of the Pull Request"}
## Looking for the symbols
To resolve the conflict we need to edit (in this case delete) one of the names and also delete all the merge text:
``` markdown
<<<<<< person-b
=======
>>>>>> main
```
This can be done in GitHub and ends with a new commit.
## Seeing the conflict locally
To see the same conflicted files locally:
1. On the branch with the conflict (`person-b`)
1. Go to the `Console` ($) and type `usethis::pr_merge_main()`
. . .
```markdown
✔ Pushing local 'author_change' branch to 'origin/author_change'.
• Create PR at link given below
✔ Opening URL 'https://github.com/Letxuga007/project/compare/author_change'
> usethis::pr_merge_main()
✔ Pulling changes from 'origin/main'.
Merge has resulted in merge conflict(s).
There are 1 conflicted files:
* 'my_report.qmd'
Are you ready to sort this out?
If so, we will open the conflicted files for you to edit.
1: Yes, I'm ready to resolve the merge conflicts.
2: No, I want to abort this merge.
Selection:
```
## End session