LoginSignup
18
11

More than 5 years have passed since last update.

概要

git stage / git unstage というコマンドが便利。

git stagegit add のシノニム(synonym)。

Git - git-stage Documentation
https://git-scm.com/docs/git-stage

git unstage というコマンドは存在しないので、エイリアス(alias)を作る。

~/.gitconfig
[alias]
    unstage = reset HEAD

使い方

readme というファイルを編集していると想定する。

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   readme

no changes added to commit (use "git add" and/or "git commit -a")

git stagereadme ファイルを staged 状態にする。

$ git stage .
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   readme

先ほど作った git unstage を使う。stagedunstaged 状態に戻る。

$ git unstage
Unstaged changes after reset:
M   readme

$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   readme

no changes added to commit (use "git add" and/or "git commit -a")

まとめ

既存のコマンドの代わりに覚えやすい別名を使うことで、脳のメモリ(記憶)を節約する。

:pensive: :blush:
git add git stage
git reset HEAD git unstage
18
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
11