The best way to make git turn a blind eye to my changes

Is there a cleaner way to make Git just ignore some of my changes and never comment on them? .gitattributes:

  config_to_be_deviated.xml filter = qqq

.git / config:

  [filter "qqq"]
  clean = "perl -ne 'print unless / git_please_dont_look_here /'"
  smudge = (Q = $ (mktemp) && cat> $ Q && patch -s $ Q </ tmp / pp && cat $ Q && rm $ Q)

The patch / tmp / pp adds my changes with "git_please_dont_look_here" on each line. Git deletes all such lines before getting the file to the repository and reads my changes when checking it; I can continue to add and make useful changes to config_to_be_deviated.xml , but the changes in the patch will not be visible with Git.

+2
source share
5 answers

It seems this filter approach is best for me.

Pros:

  • No need to use custom scripts or special commands every time. One-time setup.
  • No extra commit in history or in cache. Pure differences and corrections.
  • Low risk of doing the wrong thing.
  • It is relatively easy to make small deviations (for example, to redefine the port number in the configuration file), as a simple sed script for both blurring and cleaning.

Minuses:

  • Filtering programs run every time Git reads or writes a file; it can be slow (especially on Windows).
+1
source

Put them in a separate file, ignore the file in git and connect it to your assembly so that it is included?

+1
source

try git update-index --assume-unchanged --<path> . It acts like gitignore for files under source control. The original purpose of this feature was to improve git performance by checking for changes to a folder with a large number of files. Here is the doco :

- suppose no change
--no-assume-no change

When these flags are specified, the object names recorded for the path are not updated. Instead, these parameters are set and disabled without changes "for paths. The" accept without changes "bit is turned on, git ceases to check the working tree files for possible changes, so you need to manually disable the bit to tell git when changing the working tree file. Sometimes it is useful when working with a large project on a file system with a very slow lstat (2) system call (e.g. cifs).

This option can also be used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for non-tracked files). You must remember that the explicit operation of adding git will all the same result in the file being updated from the working tree. git (elegantly) if it is necessary to modify this file in the index, for example, when merging into a commit; Thus, if the alleged undistorted file is modified upstream, you will need to edit the situation manually.

+1
source
  • Put the default canonical configuration in the git tree, but don't play with it. This is in the tree, and if you make changes to it, they will be committed.
  • The software looks for the default configuration, but also looks for the configuration in the developer's home directory. If he finds both, he combines the two. Any configuration items found in the developer configuration file override the configuration files in the default configuration file.

The default configuration is now tracked, and your default settings are not.

+1
source

Not everyone is familiar with git to me. With Mercurial, I use a patch queue (MQ) or a shelf (similar to git stash) for such things.

git stash can be conveniently used if you can β€œlocalize” information easily (for example, all in one configuration file).

Using the fix queue is a bit more complicated, but after the proper configuration, because you can manage the localized information in a transparent push / pop way. You can find the patch queue list on top of git here on SO .

0
source

Source: https://habr.com/ru/post/1307471/


All Articles