There are ways to write in
.git / info / exclude not to manage files with Git.
These methods are for files that have not been managed with Git yet.
However, There are times when you want to ignore files that are already managed with Git locally
For example, you want to exclude from Git's management, such as when you modify the application's configuration file for local use.
In this post, I will explain the Git command which can ignore files even if they are already managed by Git.
There are two ways
git update-index --skip-worktree
git update-index --assume-unchanged
--skip-worktree is the flag which means the files should change locally.
That is, Use the command when you want to modify files managed by Git locally (or updated automatically) but you do not want Git to manage that change.
Because the command is to prevent local changes from being managed by Git, we will use the command in most cases.
$ git update-index --skip-worktree path/to/file
$ git ls-files -v | grep ^S
git ls-filesshows all files managed by git.
-vcheck the file being ignored.
--skip-worktreeis displayed with
$ git update-index --no-skip-worktree path/to/file
--assume-unchanged is the flag which means the files should not change locally.
In other words, it is used when ignore files that you do not need to change locally (or should not change).
--assume-unchanged is used when you want to speed up Git's behavior by ignoring unnecessary files.
Also, since it is an idea to ignore local changes,
git reset - hard command will delete local changes.
$ git update-index --assume-unchanged path/to/file
git ls-files -v | grep ^h
assume-unchangedis displayed with
git update-index --no-assume-unchanged path/to/file