LoginSignup
1
1

More than 1 year has passed since last update.

【Git】誤ったブランチで作業した場合の対処法

Posted at

対処法

以下のコマンドを実行して変更を正しいブランチに移動します。

git stash push

git switch 正しいブランチ

git stash pop
  • git stash push
    変更を一時退避する。
    Untracked filesも含める場合には-uを追加する。
  • git switch ブランチ
    ブランチを移動する。
  • git stash pop
    一時退避させた変更を反映する。
    同時に退避したデータを削除する。
    正しいブランチがない場合にはgit stash branch <branchname>を実行するとブランチの作成と退避した変更の反映が同時に実行できる。
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