Git:git stashコマンドですべてのファイル(未追跡と無視ファイル含めて)を退避する方法

スポンサーリンク

git stashコマンドですべてのファイル(未追跡と無視ファイル含めて)を退避する方法

git stashコマンドですべてのファイル(未追跡と無視ファイル含めて)を退避するにはpushサブコマンドで-aオプションを指定します。

 

オプションの説明

 -a, --all
     This option is only valid for push and save commands.

     All ignored and untracked files are also stashed and then cleaned up with git clean.

 

-aオプションを指定した場合

$ git status --ignored
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   a.txt
        new file:   b.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        c.txt

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        d.obj

$ git stash push -a
Saved working directory and index state WIP on master: 8b7c11b866 The fifth batch

$ git status --ignored
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

 

-aオプションを指定しない場合

$ git status --ignored
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   a.txt
        new file:   b.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        c.txt

Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        d.obj

$ git stash push
Saved working directory and index state WIP on master: 8b7c11b866 The fifth batch

$ git status --ignored
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        c.txt
Ignored files:
  (use "git add -f <file>..." to include in what will be committed)
        d.obj

nothing to commit, working tree clean
Git:git stashコマンドでUntracked files(未追跡ファイル)も退避する方法
git stashコマンドでUntracked files(未追跡ファイル)も退避する方法 git stashコマンドでUntracked files(未追跡ファイル)も退避するにはpushサブコマンドで-uオプションを指定します。 オプシ...