Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
11
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

git stage / unstage

概要

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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
11
Help us understand the problem. What are the problem?