Git:git stashコマンドでUntracked files(未追跡ファイル)も退避する方法

スポンサーリンク

git stashコマンドでUntracked files(未追跡ファイル)も退避する方法

git stashコマンドでUntracked files(未追跡ファイル)も退避するにはpushサブコマンドで-uオプションを指定します。

 

オプションの説明

 -u, --include-untracked, --no-include-untracked
     When used with the push and save commands, all untracked files are also stashed and then cleaned up with git clean.

     When used with the show command, show the untracked files in the stash entry as part of the diff.

 

-uオプションを指定した場合(Ignored fileは退避されない)

$ 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 -u
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'.

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

nothing to commit, working tree clean

 

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

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