Adding/Changing gitignore entries during development

We are knee deep into a .net core 1.0 RTM website project.  While trying to get automated builds to work (more on my "forced project.json for 4.6 DLL and .net core" frustration later), I discovered that GIT was including project.lock.json files in the commit. 

I realized that we never upgraded our .gitignore file to incldue the new DNX file omissions.   This is easier than I originally expected:

Step #1 Identify your desired changes

I found https://www.gitignore.io/, helpful in that it produces template .gitignore files based on your desired development environment. 

To fast-forward, here is the latest for Visual Studio 2015 Update 3, which includes DNX/.net core 1.0 omissions.

Step #2 Make the changes and apply to the repo branch 

Here you have 2 options, either: 

  1. Physically remove the .gitignore file from the repo, commit your change (removal), then add it back, make your desired changes from Step 1 and commit again.  
  2. Leave the .gitignore file , but remove it from the index using:
    git rm --cached project.lock.json

I completed option A and it worked perfectly.

3 Comments

  • There is another way to change gitignore entries - git update-index --assume-unchanged <file>
    and
    git update-index --no-assume-unchanged <file>
    You can read about it on Stackoverflow - http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository
    I tried you to make it the way you suggest in my project for these guys - https://magora-systems.com/mobile-application-developers-london/ - and it works just fine too. Thanks

  • It's great to see you blogging again, Scott!

  • Sorry, the link is no good - https://magora-systems.com/bespoke-software-development-uk/

Comments have been disabled for this content.