既にコミットされているファイルを無視する gitignore ? update-index
To ignore uncommitted changes in a file that is already tracked
use git update-index –assume-unchanged.
ということで。既にトラックされているファイルを無視するには
例)既にコミットされている web/index.php の変更をコミットしたくない場合。
$ git status
# On branch master
# Changes not staged for commit:
# (use “git add…” to update what will be committed)
# (use “git checkout —…” to discard changes in working directory)
#
# modified: web/index.php
# On branch master
# Changes not staged for commit:
# (use “git add
# (use “git checkout —
#
# modified: web/index.php
.gitignoreに入れても無視されません。
update-indexを行う。
$ git update-index –assume-unchanged web/index.php
$ git status
$ git status
これで web/index.php を認識しなくなります。
戻す。–no-assume-unchanged で。
$ git update-index –no-assume-unchanged web/index.php
$ git status
# On branch master
# Changes not staged for commit:
# (use “git add…” to update what will be committed)
# (use “git checkout —…” to discard changes in working directory)
#
# modified: web/index.php
$ git status
# On branch master
# Changes not staged for commit:
# (use “git add
# (use “git checkout —
#
# modified: web/index.php
開発中の設定など、間違えてコミットしないようにします。
–assume-unchanged
–no-assume-unchanged
When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the “assume unchanged” bit for the paths. When the “assume unchanged” bit is on, git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).
–no-assume-unchanged
When these flags are specified, the object names recorded for the paths are not updated. Instead, these options set and unset the “assume unchanged” bit for the paths. When the “assume unchanged” bit is on, git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).
This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what .gitignore does for untracked files). Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.
- Prev 共有・評価。共感・対立・批判。最近感じた共有や評価に関するメモ
- Next 千世倭樓 そば 美蔵
- Prev .gitignore
- Next remove a remote branch | git