既にコミットされているファイルを無視する 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

.gitignoreに入れても無視されません。

update-indexを行う。

$ git update-index –assume-unchanged web/index.php
$ 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

開発中の設定など、間違えてコミットしないようにします。

–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).

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.

This entry was posted on 月曜日, 2月 27th, 2012 at 3:28 PM and is filed under git. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。