事象
master
ブランチを親とするfeature
ブランチをチェックアウトした状態でgit pull origin master
をしたら、「error: Your local changes to the following files would be overwritten by merge」となった。
$ git branch
master
* feature
$ git pull origin master
From github.com:Example-Git/api-repo
* branch master -> FETCH_HEAD
Updating 5966be1..1c8aaff
error: Your local changes to the following files would be overwritten by merge:
Makefile
Please commit your changes or stash them before you merge.
Aborting
原因
master
ブランチの変更により上書きされるファイルMakefile
が、ローカルのfeature
ブランチで変更されたまま未コミットであったためだった。
$ git status
On branch feature
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: Makefile
no changes added to commit (use "git add" and/or "git commit -a")
解消
Makefile
の変更はコミット不要だったので、git checkout
により変更を破棄したら正常にgit pull origin master
できた。
$ git checkout Makefile
$ git status
On branch feature
nothing to commit, working tree clean
$ git pull origin master
From github.com:Example-Git/api-repo
* branch master -> FETCH_HEAD
Updating 5966be1..1c8aaff
Fast-forward
Makefile | 3 +-
sam.yml | 26 +
2 files changed, 28 insertions(+), 1 deletions(-)
create mode 100644 src/handlers/__init__.py
以上