Skip to content

Commit

Permalink
how-to: RESOLVE merge conflicts (#3929)
Browse files Browse the repository at this point in the history
* how-to: RESOLVE merge conflicts
closes #3915

* how-to: update links and add redirect
See prev commit

* how-to: clarify when git merge driver works
per #3915 (comment)

* how-to: add redirect

* Update content/docs/user-guide/how-to/resolve-merge-conflicts.md
  • Loading branch information
jorgeorpinel authored Sep 12, 2022
1 parent 64c3abd commit 1367692
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion content/docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"stop-tracking-data",
"update-tracked-data",
"add-deps-or-outs-to-a-stage",
"merge-conflicts",
"resolve-merge-conflicts",
"share-a-dvc-cache"
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title: 'How to Merge Conflicts'
title: 'How to Resolve Merge Conflicts in DVC'
description: 'Git merge conflicts can happen in DVC files when combining changes
from multiple team members.'
---

# How to Merge Conflicts in DVC Files
# How to Resolve Merge Conflicts in DVC Metafiles

Sometimes multiple team members work on the the same DVC-tracked data. When the
time comes to combine their changes, merge conflicts can occur in Git-tracked
Expand Down Expand Up @@ -35,7 +35,7 @@ stages:
## `dvc.lock`

There's no need to resolve lock file conflicts manually. You can safely
There's no need to resolve lock file merge conflicts manually. You can safely
overwrite this file by using `dvc repro` after merging `dvc.yaml`.

> `dvc commit` can also be a good option, but only for the specific case where
Expand Down Expand Up @@ -82,16 +82,14 @@ versions, then you can follow this process:

### Append-only directories

If you have an "append-only" dataset, where people only add new
files/directories, DVC provides a so-called
[merge-driver](https://git-scm.com/docs/git-merge#Documentation/git-merge.txt-mergeltdrivergtname)
that can automatically resolve Git conflicts for you. To use it, first set it up
in your Git repo:
If you have an "append-only" dataset (where people only add new
files/directories) DVC provides a [Git merge driver] that can automatically
resolve merge conflicts for you. To use it, first set it up in your Git repo:

```dvc
$ git config merge.dvc.name 'DVC merge driver'
$ git config merge.dvc.driver \
'dvc git-hook merge-driver --ancestor %O --our %A --their %B'
'dvc git-hook merge-driver --ancestor %O --our %A --their %B'
```

And add this line to your `.gitattributes` (in the root of your git repo):
Expand All @@ -103,9 +101,12 @@ mydataset.dvc merge=dvc
Now, when a merge conflict occurs, DVC will simply combine data from both
branches.

[git merge driver]:
https://git-scm.com/docs/git-merge#Documentation/git-merge.txt-mergeltdrivergtname

### Imported data

To resolve conflicted `.dvc` files generated by `dvc import` or
To resolve merge conflicts in `.dvc` files generated by `dvc import` or
`dvc import-url`, remove the conflicted values altogether:

```yaml
Expand Down
2 changes: 1 addition & 1 deletion content/docs/user-guide/project-structure/dvc-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ human-friendly schema described below. We encourage you to get familiar with it
so you may modify, write, or generate `.dvc` files on your own.

> See also
> [How to Merge Conflicts](/doc/user-guide/how-to/merge-conflicts#dvc-files).
> [How to Merge Conflicts](/doc/user-guide/how-to/resolve-merge-conflicts#dvc-files).

## Specification

Expand Down
2 changes: 1 addition & 1 deletion content/docs/user-guide/project-structure/dvcyaml-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ editors like [VSCode](/doc/install/plugins#visual-studio-code) or
validation and auto-completion.

> See also
> [How to Merge Conflicts](/doc/user-guide/how-to/merge-conflicts#dvcyaml).
> [How to Merge Conflicts](/doc/user-guide/how-to/resolve-merge-conflicts#dvcyaml).

<admon type="warn">

Expand Down
3 changes: 2 additions & 1 deletion redirects-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@

"^/doc/user-guide/updating-tracked-files$ /doc/user-guide/how-to/update-tracked-data",
"^/doc/user-guide/how-to/update-tracked-files$ /doc/user-guide/how-to/update-tracked-data",
"^/doc/user-guide/merge-conflicts$ /doc/user-guide/how-to/merge-conflicts",
"^/doc/user-guide/merge-conflicts$ /doc/user-guide/how-to/resolve-merge-conflicts",
"^/doc/user-guide/how-to/merge-conflicts$ /doc/user-guide/how-to/resolve-merge-conflicts",
"^/doc/user-guide/dvc-file-format$ /doc/user-guide/project-structure",
"^/doc/user-guide/dvc-files$ /doc/user-guide/project-structure",
"^/doc/user-guide/dvc-files/dvc-yaml$ /doc/user-guide/project-structure",
Expand Down

0 comments on commit 1367692

Please sign in to comment.