LoginSignup
0
0

More than 5 years have passed since last update.

Git ignore file

Posted at

1) To start ignoring changes to a single already versioned file

git update-index --assume-unchanged "main/dontcheckmein.txt"
and to undo that
git update-index --no-assume-unchanged "main/dontcheckmein.txt"

check here

2) To completely ignore a specific single file preventing it from being created at repository

First look at this Git global ignore not working

and at .gitignore add the relative path to the file without leading ./

so if your file is at MyProject/MyFolder/myfile.txt (where .git is also at MyProject), at .gitignore you put just this MyFolder/myfile.txt

you can confirm what rule is related to the ignore with git check-ignore "MyFolder/myfile.txt"

About global ignore

That link speaks about ~/.gitignore_global; but the file is related to your project; so, if you put the exclude pattern MyFolder/myfile.txt at ~/.gitignore_global, it will work but will not make much sense...

In the other hand, if you setup your project with git config core.excludesfile .gitignore where .gitignore is at MyProject; that setup will override ~/.gitignore_global that can have very useful rules...

So, for now, I think the best is to make some script to mix your .gitignore with ~/.gitignore_global at .gitignore.

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0