Questions tagged [git-merge-conflict]

Questions about resolving merge conflicts in Git.

See also

518 questions
5331
votes
36 answers

How do I resolve merge conflicts in a Git repository?

How do I resolve merge conflicts in my Git repository?
Spoike
  • 119,724
  • 44
  • 140
  • 158
3154
votes
14 answers

I ran into a merge conflict. How do I abort the merge?

I used git pull and had a merge conflict: unmerged: some_file.txt You are in the middle of a conflicted merge. How do I abandon my changes to the file and keep only the pulled changes?
Gwyn Morfey
  • 32,741
  • 6
  • 25
  • 21
1955
votes
19 answers

Resolve Git merge conflicts in favor of their changes during a pull

How do I resolve a git merge conflict in favor of pulled changes? I want to remove all conflicting changes from a working tree without having to go through all of the conflicts with git mergetool, while keeping all conflict-free changes. Preferably,…
sanmai
  • 29,083
  • 12
  • 64
  • 76
973
votes
7 answers

How to undo a git merge with conflicts

I am on branch mybranch1. mybranch2 is forked from mybranch1 and changes were made in mybranch2. Then, while on mybranch1, I have done git merge --no-commit mybranch2 It shows there were conflicts while merging. Now I want to discard everything (the…
Anshul
  • 9,731
  • 3
  • 15
  • 4
918
votes
23 answers

What's the simplest way to list conflicted files in Git?

I just need a plain list of conflicted files. Is there anything simpler than: git ls-files -u | cut -f 2 | sort -u or: git ls-files -u | awk '{print $4}' | sort | uniq I guess I could set up a handy alias for that, however was wondering how pros…
inger
  • 19,574
  • 9
  • 49
  • 54
526
votes
1 answer

Git conflict markers

After I pulled from remote branch, I got conflict, when I open the file it looks something like below: <<<<<<< HEAD:file.txt Hello world ======= Goodbye >>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt I need some explanations of the…
Mellon
  • 37,586
  • 78
  • 186
  • 264
347
votes
21 answers

Git error on commit after merge - fatal: cannot do a partial commit during a merge

I ran a git pull that ended in a conflict. I resolved the conflict and everything is fine now (I used mergetool also). When I commit the resolved file with git commit file.php -m "message" I get the error: fatal: cannot do a partial commit during a…
pMan
  • 8,808
  • 11
  • 32
  • 35
334
votes
4 answers

Choose Git merge strategy for specific files ("ours", "mine", "theirs")

I am in the middle of rebasing after a git pull --rebase. I have a few files that have merge conflicts. How can I accept "their" changes or "my" changes for specific files? $ git status # Not currently on any branch. # You are currently…
Steven Wexler
  • 16,589
  • 8
  • 53
  • 80
235
votes
3 answers

How do I use vimdiff to resolve a git merge conflict?

I just merged a branch into my master in git and I got Automatic merge failed; fix conflicts and then commit the result. Now I ran git mergetool and vimdiff opened with the image below. I don't know how to use vimdiff. What does each panel here mean…
Cool Guy Yo
  • 5,910
  • 14
  • 59
  • 89
212
votes
2 answers

How can I discard remote changes and mark a file as "resolved"?

I have some local files, I pull from remote branch and there are conflicts. I know that I would like to keep my local changes and ignore the remote changes causing conflicts. Is there a command I can use to in effect say "mark all conflicts as…
Tom DeMille
  • 3,207
  • 3
  • 23
  • 30
128
votes
6 answers

Git merge left HEAD marks in my files

I tried to merge a file in the command line using Git, when an error message appeared telling me the merge was aborted. I thought that was the end of it, but then I realized there are gitmarks in my files. Like so: start = expression validchar…
lowerkey
  • 8,105
  • 17
  • 68
  • 102
110
votes
11 answers

What I can do to resolve "1 commit behind master"?

After pushing I've been seeing this message at remote repository: 1 commit behind master. This merge has conflicts that must be resolved before it can be committed. To manually merge these changes into TA20footerLast run the following commands: git…
106
votes
5 answers

Is there some kind of 'git rebase --dry-run', which would notify me of conflicts in advance?

I'm trying to script rebasing and my script will take different paths depending on if the rebase results in any conflicts. Is there a way to determine if a rebase would result in conflicts before executing the rebase?
Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115
79
votes
6 answers

How to prevent many git conflicts when rebasing many commits?

Story: in the middle of a project my colleague created a new branch from master and started doing her heavy re-factoring work. I created my branch from master and started doing new stuff on the page. We are committing regularly, but only I can…
equivalent8
  • 13,754
  • 8
  • 81
  • 109
57
votes
3 answers

hint: after resolving the conflicts, mark the corrected paths

git sometimes gives me this message on a conflict (during a revert or cherry pick) hint: after resolving the conflicts, mark the corrected paths What does this mean?
paullb
  • 4,293
  • 6
  • 37
  • 65
1
2 3
34 35