Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • F first-contributions
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 322
    • Merge requests 322
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • First Contributions
  • first-contributions
  • Merge requests
  • !9695

Resolving conflicts

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/rootally/root into master 6 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: rootally

Compare
  • master (base)

and
  • latest version
    60b0e850
    1 commit, 2 years ago

1 file
+ 58
- 0

    Preferences

    File browser
    Compare changes
additional-material/git_workflow_scenarios/resolving-merge-conflicts.md
+ 58
- 0
  • View file @ 60b0e850


@@ -33,3 +33,61 @@ You can also download different plugins depending on the IDE you are using for a
# How to undo a merge?
If you want to undo a merge then you can do `git merge —abort`
# 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.
Open Terminal.
Navigate into the local Git repository that has the merge conflict.
```
cd REPOSITORY-NAME
```
Generate a list of the files affected by the merge conflict. In this example, the file README.md has a merge conflict.
```
$ git status
# On branch master
# Your branch and 'origin/master' 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 ..." as appropriate to mark resolution)
#
# deleted by us: README.md
#
# no changes added to commit (use "git add" and/or "git commit -a")
```
Open your favorite text editor, such as Atom, and navigate to the file that has merge conflicts.
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:
```
$ git add README.md
```
To remove this file from your repository:
```
$ git rm README.md
README.md: needs merge
rm 'README.md'
```
Commit your changes with a comment.
```
$ 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
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Administrator
Reference: firstcontributions/first-contributions!9695
Source branch: github/fork/rootally/root

Menu

Explore Projects Groups Snippets