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
Copy file name to clipboardExpand all lines: docs/gitgraph.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,6 +182,37 @@ After this we made use of the `checkout` keyword to set the current branch as `m
182
182
After this we merge the `develop` branch onto the current branch `main`, resulting in a merge commit.
183
183
Since the current branch at this point is still `main`, the last two commits are registered against that.
184
184
185
+
### Cherry Pick commit from another branch
186
+
Similar to how 'git' allows you to cherry pick a commit from **another branch** onto the **current** branch, Mermaid also suports this functionality. You can also cherry pick a commit from another branch using the `cherry-pick` keyword.
187
+
188
+
To use the `cherry-pick` keyword, you must specify the id using the `id` attribute, followed by `:` and your desired commit id within `""` quote. For example:
189
+
190
+
`cherry-pick id: "your_custom_id"`
191
+
192
+
Here, a new commt representing the cherry pick is created on the current branch, and is visually highlighted in the diagram with a **cherry** and a tag depicting the commit id from which it is cherry picked from.
193
+
194
+
Few Important rules to note here are:
195
+
1. You need to provide the `id` for an existing commit to be cherry picked. If given commit id does not exist it will result in an error. For this make use of the `commit id:$value` format of declaring commits. See the examples from above.
196
+
2. The given commit must not exist on the current branch. Cherry picked commit must always be a different branch than the current branch.
197
+
3. Current branch must have atleast one commit, before you can cherry pick a commit, otherwise it will case an error is throw.
198
+
199
+
Let see an example:
200
+
```mermaid-example
201
+
gitGraph
202
+
commit id: "ZERO"
203
+
branch develop
204
+
commit id:"A"
205
+
checkout main
206
+
commit id:"ONE"
207
+
checkout develop
208
+
commit id:"B"
209
+
checkout main
210
+
commit id:"TWO"
211
+
cherry-pick id:"A"
212
+
commit id:"THREE"
213
+
checkout develop
214
+
commit id:"C"
215
+
```
185
216
## Gitgraph specific configuration options
186
217
In Mermaid, you have the option to configure the gitgraph diagram. You can configure the following options:
187
218
-`showBranches` : Boolean, default is `true`. If set to `false`, the branches are not shown in the diagram.
0 commit comments