1
0
mirror of synced 2025-12-25 02:17:36 -05:00

directory deletions and creations with new index

This commit is contained in:
Jules Parker
2021-10-06 14:26:53 +02:00
parent 31ecb49aea
commit 78271efc74
63 changed files with 22 additions and 10 deletions

View File

@@ -0,0 +1,42 @@
---
title: About merge conflicts
intro: 'Merge conflicts happen when you merge branches that have competing commits, and Git needs your help to decide which changes to incorporate in the final merge.'
redirect_from:
- /github/collaborating-with-issues-and-pull-requests/addressing-merge-conflicts/about-merge-conflicts
- /articles/about-merge-conflicts
- /github/collaborating-with-issues-and-pull-requests/about-merge-conflicts
- /github/about-merge-conflicts
versions:
fpt: '*'
ghes: '*'
ghae: '*'
topics:
- Pull requests
---
Git can often resolve differences between branches and merge them automatically. Usually, the changes are on different lines, or even in different files, which makes the merge simple for computers to understand. However, sometimes there are competing changes that Git can't resolve without your help. Often, merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file.
You must resolve all merge conflicts before you can merge a pull request on {% data variables.product.product_name %}. If you have a merge conflict between the compare branch and base branch in your pull request, you can view a list of the files with conflicting changes above the **Merge pull request** button. The **Merge pull request** button is deactivated until you've resolved all conflicts between the compare branch and base branch.
![merge conflict error message](/assets/images/help/pull_requests/merge_conflict_error_on_github.png)
## Resolving merge conflicts
To resolve a merge conflict, you must manually edit the conflicted file to select the changes that you want to keep in the final merge. There are a couple of different ways to resolve a merge conflict:
- If your merge conflict is caused by competing line changes, such as when people make different changes to the same line of the same file on different branches in your Git repository, you can resolve it on {% data variables.product.product_name %} using the conflict editor. For more information, see "[Resolving a merge conflict on {% data variables.product.prodname_dotcom %}](/articles/resolving-a-merge-conflict-on-github)."
- For all other types of merge conflicts, you must resolve the merge conflict in a local clone of the repository and push the change to your branch on {% data variables.product.product_name %}. You can use the command line or a tool like [{% data variables.product.prodname_desktop %}](https://desktop.github.com/) to push the change. For more information, see "[Resolving a merge conflict on the command line](/articles/resolving-a-merge-conflict-using-the-command-line)."
If you have a merge conflict on the command line, you cannot push your local changes to {% data variables.product.product_name %} until you resolve the merge conflict locally on your computer. If you try merging branches on the command line that have a merge conflict, you'll get an error message. For more information, see "[Resolving a merge conflict using the command line](/articles/resolving-a-merge-conflict-using-the-command-line/)."
```shell
$ git merge <em>BRANCH-NAME</em>
> Auto-merging styleguide.md
> CONFLICT (content): Merge conflict in styleguide.md
> Automatic merge failed; fix conflicts and then commit the result
```
## Further reading
- "[About pull request merges](/articles/about-pull-request-merges/)"
- "[About pull requests](/articles/about-pull-requests/)"
- "[Resolving a merge conflict using the command line](/articles/resolving-a-merge-conflict-using-the-command-line)"
- "[Resolving a merge conflict on GitHub](/articles/resolving-a-merge-conflict-on-github)"

View File

@@ -0,0 +1,19 @@
---
title: Addressing merge conflicts
intro: 'If your changes have merge conflicts with the base branch, you must address the merge conflicts before you can merge your pull request''s changes.'
redirect_from:
- /github/collaborating-with-issues-and-pull-requests/addressing-merge-conflicts/
- /articles/addressing-merge-conflicts
versions:
fpt: '*'
ghes: '*'
ghae: '*'
topics:
- Pull requests
children:
- /about-merge-conflicts
- /resolving-a-merge-conflict-on-github
- /resolving-a-merge-conflict-using-the-command-line
shortTitle: Address merge conflicts
---

View File

@@ -0,0 +1,62 @@
---
title: Resolving a merge conflict on GitHub
intro: 'You can resolve simple merge conflicts that involve competing line changes on GitHub, using the conflict editor.'
redirect_from:
- /github/collaborating-with-issues-and-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github
- /articles/resolving-a-merge-conflict-on-github
- /github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github
- /github/resolving-a-merge-conflict-on-github
versions:
fpt: '*'
ghes: '*'
ghae: '*'
topics:
- Pull requests
shortTitle: Resolve merge conflicts
---
You can only resolve merge conflicts on {% data variables.product.product_name %} that are caused by competing line changes, such as when people make different changes to the same line of the same file on different branches in your Git repository. For all other types of merge conflicts, you must resolve the conflict locally on the command line. For more information, see "[Resolving a merge conflict using the command line](/articles/resolving-a-merge-conflict-using-the-command-line/)."
{% ifversion ghes or ghae %}
If a site administrator disables the merge conflict editor for pull requests between repositories, you cannot use the conflict editor on {% data variables.product.product_name %} and must resolve merge conflicts on the command line. For example, if the merge conflict editor is disabled, you cannot use it on a pull request between a fork and upstream repository.
{% endif %}
{% warning %}
**Warning:** When you resolve a merge conflict on {% data variables.product.product_name %}, the entire [base branch](/github/getting-started-with-github/github-glossary#base-branch) of your pull request is merged into the [head branch](/github/getting-started-with-github/github-glossary#head-branch). Make sure you really want to commit to this branch. If the head branch is the default branch of your repository, you'll be given the option of creating a new branch to serve as the head branch for your pull request. If the head branch is protected you won't be able to merge your conflict resolution into it, so you'll be prompted to create a new head branch. For more information, see "[About protected branches](/github/administering-a-repository/about-protected-branches)."
{% endwarning %}
{% data reusables.repositories.sidebar-pr %}
1. In the "Pull Requests" list, click the pull request with a merge conflict that you'd like to resolve.
1. Near the bottom of your pull request, click **Resolve conflicts**.
![Resolve merge conflicts button](/assets/images/help/pull_requests/resolve-merge-conflicts-button.png)
{% tip %}
**Tip:** If the **Resolve conflicts** button is deactivated, your pull request's merge conflict is too complex to resolve on {% data variables.product.product_name %}{% ifversion ghes or ghae %} or the site administrator has disabled the conflict editor for pull requests between repositories{% endif %}. You must resolve the merge conflict using an alternative Git client, or by using Git on the command line. For more information see "[Resolving a merge conflict using the command line](/articles/resolving-a-merge-conflict-using-the-command-line)."
{% endtip %}
{% data reusables.pull_requests.decide-how-to-resolve-competing-line-change-merge-conflict %}
![View merge conflict example with conflict markers](/assets/images/help/pull_requests/view-merge-conflict-with-markers.png)
1. If you have more than one merge conflict in your file, scroll down to the next set of conflict markers and repeat steps four and five to resolve your merge conflict.
1. Once you've resolved all the conflicts in the file, click **Mark as resolved**.
![Click mark as resolved button](/assets/images/help/pull_requests/mark-as-resolved-button.png)
1. If you have more than one file with a conflict, select the next file you want to edit on the left side of the page under "conflicting files" and repeat steps four through seven until you've resolved all of your pull request's merge conflicts.
![Select next conflicting file if applicable](/assets/images/help/pull_requests/resolve-merge-conflict-select-conflicting-file.png)
1. Once you've resolved all your merge conflicts, click **Commit merge**. This merges the entire base branch into your head branch.
![Resolve merge conflicts button](/assets/images/help/pull_requests/merge-conflict-commit-changes.png)
1. If prompted, review the branch that you are committing to.
If the head branch is the default branch of the repository, you can choose either to update this branch with the changes you made to resolve the conflict, or to create a new branch and use this as the head branch of the pull request.
![Prompt to review the branch that will be updated](/assets/images/help/pull_requests/conflict-resolution-merge-dialog-box.png)
If you choose to create a new branch, enter a name for the branch.
If the head branch of your pull request is protected you must create a new branch. You won't get the option to update the protected branch.
Click **Create branch and update my pull request** or **I understand, continue updating _BRANCH_**. The button text corresponds to the action you are performing.
1. To merge your pull request, click **Merge pull request**. For more information about other pull request merge options, see "[Merging a pull request](/articles/merging-a-pull-request/)."
## Further reading
- "[About pull request merges](/articles/about-pull-request-merges)"

View File

@@ -0,0 +1,129 @@
---
title: Resolving a merge conflict using the command line
intro: You can resolve merge conflicts using the command line and a text editor.
redirect_from:
- /github/collaborating-with-issues-and-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line
- /articles/resolving-a-merge-conflict-from-the-command-line/
- /articles/resolving-a-merge-conflict-using-the-command-line
- /github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-using-the-command-line
versions:
fpt: '*'
ghes: '*'
ghae: '*'
topics:
- Pull requests
shortTitle: Resolve merge conflicts in Git
---
Merge conflicts occur when competing changes are made to the same line of a file, or when one person edits a file and another person deletes the same file. For more information, see "[About merge conflicts](/articles/about-merge-conflicts/)."
{% tip %}
**Tip:** You can use the conflict editor on {% data variables.product.product_name %} to resolve competing line change merge conflicts between branches that are part of a pull request. For more information, see "[Resolving a merge conflict on GitHub](/articles/resolving-a-merge-conflict-on-github)."
{% endtip %}
## Competing line change merge conflicts
To resolve a merge conflict caused by competing line changes, you must choose which changes to incorporate from the different branches in a new commit.
For example, if you and another person both edited the file _styleguide.md_ on the same lines in different branches of the same Git repository, you'll get a merge conflict error when you try to merge these branches. You must resolve this merge conflict with a new commit before you can merge these branches.
{% data reusables.command_line.open_the_multi_os_terminal %}
2. Navigate into the local Git repository that has the merge conflict.
```shell
cd <em>REPOSITORY-NAME</em>
```
3. Generate a list of the files affected by the merge conflict. In this example, the file *styleguide.md* has a merge conflict.
```shell
$ git status
> # On branch branch-b
> # You have unmerged paths.
> # (fix conflicts and run "git commit")
> #
> # Unmerged paths:
> # (use "git add <file>..." to mark resolution)
> #
> # both modified: styleguide.md
> #
> no changes added to commit (use "git add" and/or "git commit -a")
```
4. Open your favorite text editor, such as [Atom](https://atom.io/), and navigate to the file that has merge conflicts.
5. To see the beginning of the merge conflict in your file, search the file for the conflict marker `<<<<<<<`. When you open the file in your text editor, you'll see the changes from the HEAD or base branch after the line `<<<<<<< HEAD`. Next, you'll see `=======`, which divides your changes from the changes in the other branch, followed by `>>>>>>> BRANCH-NAME`. In this example, one person wrote "open an issue" in the base or HEAD branch and another person wrote "ask your question in IRC" in the compare branch or `branch-a`.
```
If you have questions, please
<<<<<<< HEAD
open an issue
=======
ask your question in IRC.
>>>>>>> branch-a
```
{% data reusables.pull_requests.decide-how-to-resolve-competing-line-change-merge-conflict %} In this example, both changes are incorporated into the final merge:
```shell
If you have questions, please open an issue or ask in our IRC channel if it's more urgent.
```
7. Add or stage your changes.
```shell
$ git add .
```
8. Commit your changes with a comment.
```shell
$ git commit -m "Resolved merge conflict by incorporating both suggestions."
```
You can now merge the branches on the command line or [push your changes to your remote repository](/github/getting-started-with-github/pushing-commits-to-a-remote-repository/) on {% data variables.product.product_name %} and [merge your changes](/articles/merging-a-pull-request/) in a pull request.
## Removed file merge conflicts
To resolve a merge conflict caused by competing changes to a file, where a person deletes a file in one branch and another person edits the same file, you must choose whether to delete or keep the removed file in a new commit.
For example, if you edited a file, such as *README.md*, and another person removed the same file in another branch in the same Git repository, you'll get a merge conflict error when you try to merge these branches. You must resolve this merge conflict with a new commit before you can merge these branches.
{% data reusables.command_line.open_the_multi_os_terminal %}
2. Navigate into the local Git repository that has the merge conflict.
```shell
cd <em>REPOSITORY-NAME</em>
```
2. Generate a list of the files affected by the merge conflict. In this example, the file *README.md* has a merge conflict.
```shell
$ git status
> # On branch main
> # Your branch and 'origin/main' have diverged,
> # and have 1 and 2 different commits each, respectively.
> # (use "git pull" to merge the remote branch into yours)
> # You have unmerged paths.
> # (fix conflicts and run "git commit")
> #
> # Unmerged paths:
> # (use "git add/rm <file>..." as appropriate to mark resolution)
> #
> # deleted by us: README.md
> #
> # no changes added to commit (use "git add" and/or "git commit -a")
```
3. Open your favorite text editor, such as [Atom](https://atom.io/), and navigate to the file that has merge conflicts.
6. Decide if you want keep the removed file. You may want to view the latest changes made to the removed file in your text editor.
To add the removed file back to your repository:
```shell
$ git add README.md
```
To remove this file from your repository:
```shell
$ git rm README.md
> README.md: needs merge
> rm 'README.md'
```
7. Commit your changes with a comment.
```shell
$ git commit -m "Resolved merge conflict by keeping README.md file."
> [branch-d 6f89e49] Merge branch 'branch-c' into branch-d
```
You can now merge the branches on the command line or [push your changes to your remote repository](/github/getting-started-with-github/pushing-commits-to-a-remote-repository/) on {% data variables.product.product_name %} and [merge your changes](/articles/merging-a-pull-request/) in a pull request.
## Further reading
- "[About merge conflicts](/articlespull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/about-merge-conflicts)"
- "[Checking out pull requests locally](/articles/checking-out-pull-requests-locally/)"