Avoid committing your changes

If you’re working on a project where you have config files with passwords or a file with specific settings in them, for example a fabfile with different settings on different computers or a mutt config file with a server password. This is a bit risky to rely on always being vigilant and avoiding staging that hunk when building a commit. Instead, you can tell git to assume that a file is unchanged:

$ git update-index --assume-unchanged settings.py

If you often change that file, you would have to call update-index with --no-assume-unchanged before (carefully) selecting hunks for a commit, but since config files rarely change, there are no real downside to doing this.

This is how it will look:

$  git diff
    diff --git a/settings.py b/settings.py
    index a9b5c69..d0fd017 100644
    --- a/settings.py
    +++ b/settings.py
    @@ -96,7 +96,7 @@ FILTER = {

     UI_COMPRESSOR = os.path.join(ROOT_PATH, 'yuicompressor-2.4.2.jar')
     HSS_PATH = None # if you don't want to use HSS
    -LESS_CSS_PATH = '/home/max/less.js/bin/lessc'
    +LESS_CSS_PATH = '/usr/local/bin/lessc'
     THUMBNAIL_MAX_WIDTH = 1400000000
     THUMBNAIL_MAX_HEIGHT = 100
     THUMBNAIL_FILENAME_POSTFIX = '-thumb'
    $ git update-index --assume-unchanged settings.py
    $ git diff
    $ git st -s
    $
comments powered by Disqus