0

Is it possible for git to ignore a part of a file?

assume-unchanged: this can leave a complete file unchanged

git update-index --assume-unchanged -- project/pom.xml

But how can I keep one line unchanged?

In this example: pom.xml

  • Line with 14.5.FEATURE-15: This is changed for every feature branch.
  • The rest of the file can be changed and needs to be commited.
  • Context: Changing this version allows us to link with separate repositories and download the correct version during an maven build for this feature.
  • When the feature is finished, then we want to merge this back into development, but we don't want to update the development version of this pom.xml (14.5.0)
  • We have difficulty to externalize this version and would like to ignore only this line...

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    
    <modelVersion>4.0.0</modelVersion>
    <groupId>be.softwarelab.project.calculator</groupId>
    <artifactId>softwarelab-calculator</artifactId> 
    <packaging>pom</packaging>
    <version>14.5.FEATURE-15</version>
    <name>softwarelab-calculator</name>
    
    <modules>
        <module>api</module>
        <module>client</module>
        <module>common</module>
        <module>config</module>
        <module>tools</module>
        <module>core</module>
        <module>test</module>
    </modules>
    
    <properties>
    ...
    
Jongware
  • 22,200
  • 8
  • 54
  • 100
Dimitri Dewaele
  • 10,311
  • 21
  • 80
  • 127

0 Answers0