とあるエンジニアの闇歴史帳

コピペで使える便利Wiki ※現在構築中です。

ユーザ用ツール


サイドバー

言語

サーバ関連

ツール

API

読み物

その他

git:branch_move

[Git]ブランチを移動する

実行例

git checkout [ブランチ名] でブランチを移動します。

$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.

トラブルシューティング

commitしていない

ファイルの内容を変更したが、commitしていない物がある場合、ブランチを移動することができません。

$ git checkout master
error: Your local changes to the following files would be overwritten by checkout:
        hello.txt
Please, commit your changes or stash them before you can switch branches.
Aborting

git statusで該当する箇所を確認しcommitするか、もしくは破棄(git checkout [ファイル名])するなどした後に再度コマンドを実行してみてください。

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

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   hello.txt

参考

関連書籍

failed to fetch data: unkown error

failed to fetch data: unkown error

failed to fetch data: unkown error

failed to fetch data: unkown error

関連ページ

git/branch_move.txt · 最終更新: 2020/06/23 14:10 (外部編集)