Max
Max

Reputation: 7119

Avoiding merge conflicts with git

I've been using git for a while, and I understand why merge conflicts happen and that I need to make the final decision between two conflicting blocks of code.

However, I want to find a way to fix merge conflicts without git modifying the conflicting files. For example, if there are merge conflicts in a Django template or HTML file when I pull from dev into prod, the conflict lines go live on my site.

In most cases, merging is not actually what I want for a lot of HTML content I have. I usually prefer only one version of the two conflicting files.

Is there a way to achieve this?

Upvotes: 1

Views: 876

Answers (2)

Greg Hewgill
Greg Hewgill

Reputation: 993085

Could you run git pull on your production server with the --ff-only flag? That would ensure that you've already made the new changes apply cleanly on top of whatever your production server already has.

Upvotes: 0

jweyrich
jweyrich

Reputation: 32240

For example, if there are merge conflicts in a Django template or HTML file when I pull from dev into prod, the conflict lines go live on my site.

Why would merge occur in production? Don't do that. If you ever considered doing it, merge using a new branch, then push to production.

In most cases, merging is not actually what I want for a lot of HTML content I have. I usually prefer only one version of the two conflicting files.

To overwrite files/directories on your local copy, use:

git checkout <from_branch> <path1> <path2> ....

Upvotes: 4

Related Questions