One problem I keep running into and don't quite file away in my memory is how to handle settings files with sensitive information in git.

My solution is pretty simple:

  • Create a dummy file in an early commit that says, "Contains sensitive information! Contact other developers for the contents of this file."
  • Explain how to use git skip-worktree (which I've apparently blogged about before)
  • Have the new developer skip that config from their worktree.

Now this can bite you, I'm afraid. If you try to swap branches to one where the dummy file has been edited, you'll get an error that you have changes in your branch that would be overridden, even though git status or your GUI client or whatever will [almost properly] show that no chnages have been made.

How do you fix that? Here's the best I can figure (edited somewhat):

If you end up in NeverGiveUp161's situation where changing branches gives you, "Your local changes to the following files would be overwritten by checkout", the only fix I can figure is to run a git update-index --no-skip-worktree path/to/myFile.file, stash that, and then change branches.

Note that that's --no-skip-worktree with a no- in that command to remove a file from skipping.

Not super ideal, but it works.

Labels: ,