LoginSignup
1
1

More than 3 years have passed since last update.

「あ、間違えてgitのbranch切らずに編集しちゃった〜🥺🥺🥺」の対処法

Posted at

解説され尽くした方法ですが、git stashを使って**「本当は、新しくブランチを切って編集したかったのにブランチを切り替えずに編集してしまった時」に「現在Commitしてない変更を新しいブランチに移動させる方法」を解説します。

編集中だけど、とりあえずさっさとブランチを切り替えたいときにも使えます。

忙しい方むけ

$ git stash
$ git branch -b 新しいブランチ
$ git stash pop

もしくはもう少し丁寧に解説をつけると

$ git stash // 現在の変更差分を一時的に保存して直前のコミットに戻す。
$ git branch 新しいブランチ 
$ git checkout 新しいブランチ
$ git stash list // 
$ git stash apply // 現在のブランチに一時的に保存した
$ git stash

参考文献

間違って別のブランチで実装を始めちゃった時にgit stashで別ブランチに編集中のソースを移動する

1
1
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
1
1