2

So I have a few files that get "modified/set" on a per user bases.

But is it possible to ignore that single line of the "config" when committing and to not overwrite that line when doing a pull? (Other changes to the file should be committed)

Example In Git (Test.ws)

[Macro]
DIR=C:\Users\XXXXXXXXX\AppData\Roaming\Test\

Example after user edits the file

[Macro]
DIR=C:\Users\Alex\AppData\Roaming\Test\

I have looked at Git Attribute Keyword Expansion but that has the disadvantage of everything not being in the "repository". So the drivers need to be setup for every user.

If I do go with Git Attribute, how would I set it up for the above file?

Note: The file above is a .ws file. It is a file that is associated with an EXE and it executes. There is nothing "consuming" it.

PrivatMamtora
  • 2,072
  • 2
  • 19
  • 29
  • 2
    Assuming it is config files, it may be better to tease apart local and global configs into two different files. Using just git, `git add -p` allows the user to select the hunks to stage for commits. I suppose there is a way to automate the selection of hunks based on patterns (as done http://cweiske.de/tagebuch/git-add-p-auto.htm). – Venkatesh-Prasad Ranganath Jan 17 '20 at 17:16
  • 1
    Thats great for having clean commits. But what about when you pull? Would you have to do extra work to make sure the global doesn't override the local? – PrivatMamtora Jan 17 '20 at 19:13
  • 2
    Does this answer your question? [Ignore one line in a specific file in Git](https://stackoverflow.com/questions/32045399/ignore-one-line-in-a-specific-file-in-git) – Chris Maes Jan 17 '20 at 19:21
  • @ChrisMaes so there is still no other solution than configuring it each time? I was looking for another solution. (It being another decade) – PrivatMamtora Jan 17 '20 at 19:51
  • Partitioning configuration parameters into global and local sets is a clean solution that also works well with version control. Of course, the app logic would have to ensure config params from a set are loaded only from the corresponding config file; may be, by inhibiting loading of params or removing them after loading. An alternative is to use different load orders for different parameters, i.e., for param x, local followed by global. That said, I'd go with partitioning the params and falling back on defaults when unspecified. – Venkatesh-Prasad Ranganath Jan 17 '20 at 19:56
  • @Venkatesh-PrasadRanganath That works if it is a configuration file. But my file is not part of an "application" or "consumed". I added a note. – PrivatMamtora Jan 17 '20 at 21:15
  • If it is not part of or consumed by any application, what is it's reason for existing? – fredrik Jan 17 '20 at 21:18
  • @fredrik It is to be executed. Double clicked to run (FileType is associated with exe, which I don't control) – PrivatMamtora Jan 22 '20 at 20:02

0 Answers0