Marcus Leon
Marcus Leon

Reputation: 56669

Git merge: Keep certain lines in local file

We configure our app version in multiple Maven pom.xml files as:

<version>8.1.0.4-SNAPSHOT</version>

This is always a pain to handle when merging as you will always have conflicts which require manual merging. Can you configure Git to always keep the local copy of the <version>...</version> line when doing a merge?

Note we don't want to simply ignore all remote changes to the pom.xml files as there could have been non <version> changes we want to merge in. We only want to ignore changes to the <version> tag.

Note: It has been mentioned that Can git ignore a specific line? is a possible duplicate. I don't see any mention of merging in that question. Would appreciate someone describing how that translates to merging.

Upvotes: 2

Views: 272

Answers (1)

AlBlue
AlBlue

Reputation: 24040

If you have a repository enabled with git config rerere.enabled=true then it will remember the resolutions you have done and re-apply them next time you have to do them. You can also apply this for all repositories with git config --global rerere.enabled=true

Upvotes: 1

Related Questions