Home > Enterprise >  Gitignore a certain change in a certain file
Gitignore a certain change in a certain file

Time:12-11

In one of the projects, the project file is versioned in GIT in addition to the source code. Whenever programming, the IDE inserts the programmers (dedicated USB device) specific ID into the project file (XML):

enter image description here

Whenever someone else commits, it would change the line to ones ID as well. In practice, because of this, each change to source code is accompanied with the project file change here, if one forgets to discard that before committing. Is there a way for the .gitignore to have an entry, to specifically ignore the changes in this one file, for this one field?

CodePudding user response:

.gitignore works with files, not their contents. I would recommend writing a hook on commit and then add your XML parsing logic alongside actually finding/discarding this field.

CodePudding user response:

For this particular case, filters might be a reasonable option, but in the general case just checking in such changes as normal, plain commits but make the commit message stand out is very simple and only require a trivial interactive rebase before creating pull requests/merging the final result.

  • Related