0
0

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.

git checkoutしたらerror: Your local changes to the following files would be overwritten by checkout:となったときの対応方法

Last updated at Posted at 2019-07-03
  • 環境
    • CentOS Linux release 7.6.1810 (Core)
    • git version 1.8.3.1
    • xfc4-terminal 0.8.7.4

事象 : チェックアウトしたら怒られた

$ git checkout branch-c
error: Your local changes to the following files would be overwritten by checkout:
    project-name/pom.xml
    project-name/.project
    project-name/.settings/org.eclipse.wst.common.component
Please, commit your changes or stash them before you can switch branches.
Aborting

原因 : ローカルを変更したままだったから

対応 : stashしておく

Gitでstashする方法 - Qiita

もう一回チェックアウトする

$ git checkout branch-a
Branch branch-a set up to track remote branch branch-a from origin.
Switched to a new branch 'branch-a'

# 現在のブランチを確認する
$ git branch --contains=HEAD
* branch-a
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?