ステージから降ろす
- ステージ済みのものをキャンセルするには、
git reset
でファイルを指定する。
流れを確認するシェルスクリプト
- リポジトリ作成
- ステージに乗せる(
git add
)
- ステージから降ろす(
git reset
)
#!/bin/bash
# 一時ディレクトリを作り直す
rm -fr git-tmp; mkdir git-tmp; cd git-tmp
# スクリプト表示しながら実行
set -v
#--------------------------------------
# リポジトリ作成: repo
mkdir repo
cd repo
git init
#--------------------------------------
# ステージに乗せる
touch 女優 大根
git add 女優 大根
# リポジトリの状態
git status
#--------------------------------------
# ステージから降ろす
git reset 大根
# リポジトリの状態
git status
実行結果
#--------------------------------------
# リポジトリ作成: repo
mkdir repo
cd repo
git init
Initialized empty Git repository in /home/alice/git-tmp/repo/.git/
#--------------------------------------
# ステージに乗せる
touch 女優 大根
git add 女優 大根
# リポジトリの状態
git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: 大根
# new file: 女優
#
#--------------------------------------
# ステージから降ろす
git reset 大根
# リポジトリの状態
git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: 女優
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# 大根