Questions tagged [git-merge-conflict]

Questions about resolving merge conflicts in Git.

See also

518 questions
7
votes
2 answers

How to resolve a git conflict by keeping all additions from both sides?

I keep running into the following problem and I'd like to know whether there is an easy solution to it using existing git commands or whether I'll need to write a custom merge driver. Here's an example to demonstrate my problem: Say the master…
7
votes
1 answer

Git Merge vs Rebase - Resolving conflicts

This is a bit long, but I think it may be an interesting problem. We just recently started to use git in our company despite a lot of people reluctance a few managed to start using it in small projects and now we're actually using it more relevant…
prototyp3PT
  • 123
  • 1
  • 1
  • 7
7
votes
3 answers

Why is it resulting in a merge conflict?

This was the initial snapshot of my git repository On branch master, file m1 contains L1 On branch dev, file m1 contains L1 L2 If I try to merge dev from master, it results in a conflict. $ git checkout master Switched to branch 'master' $ git…
sherlock
  • 2,397
  • 3
  • 27
  • 44
6
votes
1 answer

Branching from a feature branch and reconciling commits after main squash merge

I have the following situation: I've worked on a feature branch (called work1) to which I have an outstanding PR. While I wait for the PR to be approved, I want to start working on a new feature branch (called work2). The problem is that my…
Leonardo
  • 1,533
  • 17
  • 28
6
votes
1 answer

Git file-level merge conflict caused by Git “suggesting [the file] should perhaps be moved”

I've got a Git repo of Markdown articles, where people create pull requests (one per Markdown article) that eventually get merged to master and then, working directly on master, I move that article into a folder called wordpressed and commit and…
matt
  • 515,959
  • 87
  • 875
  • 1,141
6
votes
2 answers

Why does git rebase trigger a merge conflict?

I have cloned a remote repository, create a new branch b and started working and making commits. I have also pushed the b branch, but am the only one who's working on it. After a while, I want to rebase my local branch over the remote master, just…
Aviv Cohn
  • 15,543
  • 25
  • 68
  • 131
6
votes
1 answer

How to resolve a rebase conflict when file was removed from master?

From master, the A branch was branched. Then, a few commits (to master) later, B branch was branched. The owner of A made changes to file fname. The owner of B removed fname altogether. Then, B was rebased and merged into master. Now, A is to be…
ysap
  • 7,723
  • 7
  • 59
  • 122
6
votes
1 answer

How to deal with xxx~HEAD after git merge?

In my branchA: I copy a file from folder04/config.xml to folder05/config.xml, then git add and commit. In my branchB (B is branch out from A): I already have one file named folder05/config.xml. Now I merge branchA into branchB, it appears a weird…
Corey
  • 1,217
  • 3
  • 22
  • 39
6
votes
1 answer

Github thinks branches are different after merge

I've banged my head against the wall with this Github issue enough to finally come here for help. My repo has two branches of interest: master, which is the currently live release branch, and alternate-testing, which is exactly what it sounds like.…
6
votes
0 answers

During git cherry-pick, undo changes to a single file, reverting to my version

I'm doing a cherry-pick for a large commit with multiple files. There are some conflicts, but for some of the conflicting files I'm sure that I don't need any of the changes. I'd just like to revert all changes applied to these files in that commit…
6
votes
1 answer

View git diff from individual parents

Say, I've been presented with a merge conflict, and I managed to fix it, but haven't marked as resolved (i.e. I haven't done git add conflicted files yet). At this point, I can do git diff and I'll be shown how the resultant file differs from each…
Jeenu
  • 2,109
  • 2
  • 20
  • 27
6
votes
1 answer

How can merge conflicts be avoided when different methods (etc.) are added at the same location?

Preface: this is not a general question about merge conflicts, but a very specific case that keeps bugging me. It is quite trivial, but it does amount to a (slight) hassle often enough to stand out. I am not concerned about general merging, this is…
AnoE
  • 8,048
  • 1
  • 21
  • 36
6
votes
1 answer

Merge conflict, when branches aren't modifying the same line

I'm trying to wrap my head around git conflicts, why does merging these two result in a conflict? file.txt on branch master: This is line number one file.txt on branch feature: This is line number one This is line number two
6
votes
2 answers

Git merge internals

This is probably going to end up being a long question, so please bear with me. I came across an incredible explanation for git merge decisions here: How does git merge work. I am trying to build on this explanation and see if there are any holes…
Sandman
  • 5,432
  • 5
  • 20
  • 23
5
votes
3 answers

In Git, after merging some files, I want to accept all "theirs" that are left in the merge. How do I do that?

Once I merged some files, how do I accept all the files that are still unmerged (either ours or theirs)? I tried git checkout --theirs Project\folder\*.json But that did not seem to do anything. This is different than existing questions, because I…
Shahar Prish
  • 4,838
  • 3
  • 26
  • 47