39
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

stashからapplyやpopができなくなった時。

Posted at

git stash applyやgit stash popを実行した際に、エラーが出て実行できなくなるときってありますよね?

例えば)
ブランチAで
untrackedなファイルA.txtがある状態で

git stash save -u

ブランチBで同じファイルA.txtがある状態で

git stash apply

なんてすると以下のエラーが出ます。

A.txt already exists, no checkout
Could not restore untracked files from stash

こういった場合、強制的にstash applyしたい時は以下の様にすればOK

 git merge "stash@{0}"  

そうです、stashもmerge出来るんです。
もちろんcheckoutで個別にファイルを取得することもできます。

39
37
2

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
39
37

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?