Search code examples
gitoauthcommitstage

Commit file to github and then unstage because it contains sensitive data


I"m trying to work on a Twitter Github project. I have an OAuth class that I want uploaded once to give the layout for OAuth, however after that I dont want it to be committed anymore so I can put my data in it and not have it uploaded. Is there anyway to do this?


Solution

  • You can use update-index to tell git that it should always assume that file is never changed:

    git update-index --assume-unchanged oath.class
    

    You can toggle it back by using --no-assume-unchanged

    git update-index --no-assume-unchanged oath.class
    

    Which will make git notice changes to the file again.