Search code examples
xmlgitgitignoreatmelstudio

How can I have git ignore parts of Atmel Studio's .cproj file?


We have a couple people working on a single Atmel Studio 7 project that is in a git repo. Everytime someone opens the project, Atmel Studio makes some user-specific changes to the project file (*.cproj) like adding the serial number of the debug probe and updating the exact Atmel Studio version number it was opened with. I'd like to ignore these changes, but still keep the file in the repo since it includes all of the necessary project settings.

Does anyone have a good solution to this problem?


Solution

  • You can use git update-index to accomplish what you want.

    In each user's sandbox, run this command:

    git update-index --assume-unchanged <file>
    

    This will tell Git to ignore all changes to <file> in this sandbox from now on.

    Should you ever change your mind and want to commit changes to <file>, you will have to reverse that action first, because git add and other commands just won't see any changes to a file marked assume-unchanged:

    git update-index --no-assume-unchanged <file>
    

    EDIT, two years later...

    A better solution is to use:

    git update-undex --skip-worktree <file>
    

    It's meant exactly for the use case here.