I'm new in git.
I got error message error: Your local changes to the following files would be overwritten by checkout:
after git checkout.
And I found a good question from Stack Overflow here.
But I'm still confused.
Why are my files followed to the branch that I wanted to checkout?
I expected the files are remain in local
branch and I could simply move to dev
branch without the files.
My situation
local branch that I'm focusing(all files are committed)
- add => new_file.java
- delete => deleted_file.java
- modify => modified_file.java
git checkout dev
=> error: Your local changes to the following files would be overwritten by checkout:
Edit
I figured out what happened. Sorry, my explanation above was wrong.
admin : is local branch that I'm focusing(all files are committed)
- add => new_file.java
- delete => deleted_file.java
- modify => modified_file.java
someone removed origin/admin branch, and created origin/admin/dev branch.
- my local
ㄴadmin
- origin
ㄴadmin (removed)
ㄴadmin/dev (created)
I tried checkout origin/admin/dev branch!
git checkout origin/admin/dev
- my local
ㄴadmin
ㄴadmin/dev (checkout failed)
it may failed. because my local branch's name 'admin' and remote branch's name 'admin/dev' are crashed. if branch's name is crashed, checkout is failed and the files are remain my workspace! Using the slash character in Git branch name
Sorry for the wrong explanation.