git update-index
git
書き方
git update-index [--skip-worktree|--chmod=+x] <file>索引を直接いじります。この印はローカル限りでpushされず、追跡中の設定ファイルに自分の変更を残したいときは--assume-unchangedではなく--skip-worktreeです。
よく使うオプション
| オプション | 意味 |
|---|---|
| --chmod=+x | record the executable bit, useful from Windows |
| --skip-worktree | let you keep local edits to a tracked file |
| --no-skip-worktree | undo that |
| --assume-unchanged | promise you will not edit it, as a speed hint only |
| --no-assume-unchanged | undo that |
| --refresh | update stat information after a filesystem change |
例
git update-index --chmod=+x scripts/deploy.shstages the executable bit so CI can run it
git update-index --skip-worktree config/local.jsonkeeps your local edits out of every diff
git update-index --no-skip-worktree config/local.jsonputs the file back under normal tracking
取り消しに何通りもあるのが混乱のもとです — ブランチの指す先を動かすのと、打ち消すコミットを積むのは別です。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. git update-index は何をしますか。
索引を直接いじります。この印はローカル限りでpushされず、追跡中の設定ファイルに自分の変更を残したいときは--assume-unchangedではなく--skip-worktreeです。
Q. どう打ちますか。
git update-index [--skip-worktree|--chmod=+x] <file> — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは6個です。全部は man git にあります。このコマンドはgitの仲間です。
関連するコマンド
man ページ: man git-update-index