Raffi
Raffi

Reputation: 996

How do I preserve a change locally without committing it?

Occasionally, I need to add a modification to my local copy of a git branch that I don't want to commit, such as a workaround for my computer that shouldn't be included in my team's repo. What I would like to do is, in effect, gitignore part of a committed file. There seem to be several possible methods:

  1. Add the change in my local branch and revert it before pushing. This method is simple, but not automated.
  2. Ensure that when the site builds, files are piped through a script that patches in the change. This method is simple and automated but I haven't yet looked into how to accomplish it.
  3. Use .git/info/attributes and filters to automatically patch in the change when I run git checkout and automatically remove it when I run git add. This method is automated but not simple: it makes my working tree always have uncommitted changes, which is frustrating.
  4. Use my modification only if an environment variable is set. This method would clutter the team's repo.

Is there another method, or a better way of using these methods?

Upvotes: 0

Views: 64

Answers (0)

Related Questions