# Merge

### Notes

To merge two branches, you need to first checkout the branch to merge into. Then start merging:

```
git merge <branch-name>
```

If there's no conflict, then it will be a fast-forward merge. If there're conflicts, you need to resolve the conflicts.

### Resolving conflicts

Conflicts are marked by Git in the file, e.g.

```
<<<<<<< Updated upstream
this is a new file 5 in branch2
=======
This is file 5.
>>>>>>> Stashed changes
```

You can either

* manually edit the file to the final form; or
* tell Git which version to pick using the `--ours` or `--theirs` flag
  * `git checkout --ours <file>`
  * `--ours`: the version from the current branch (the one you checkout beforehand)
  * `--theirs`: the version from the other branch.

Once the conflicts are resolved, you can then commit the changes.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yu-sun.gitbook.io/essential-git-for-scientists/cookbook/merge.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
