Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
194 views
in Technique[技术] by (71.8m points)

Git/Github: error: Your local changes to the following files would be overwritten by merge: README.md a_text_file.txt DONT EXIST

I am trying to pull from a remote repo in Github to my folder. I want to be able to pull and push changes as I have them in my IDE.

Everytime I try and pull from the repo which I have set up as remote origin I get the following error:

error: Your local changes to the following files would be overwritten by merge:
 README.md a_text_file.txt

I don't understand this at all as this a_text_file.txt is not in my directory that is linked, nor is it in my repo, yet I cannot pull until this is resolved.

I have tried to unlink and relink the remote to the repo but still the error persists.

Can anyone explain what's going on here?

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

When you try to checkout some target, it will place the contents of the target on-disk. If you have made changes on-disk, then checkout will (by default) refuse to overwrite any changes that you have made and will give you a checkout conflict:

error: The following untracked working tree files would be overwritten by checkout:
    file_one
    file_two
Please move or remove them before you switch branches.
Aborting

Note that each file that is in conflict is identified individually, one per line.

In your case, you have a conflict reported as:

README.md a_text_file.txt

In this case, this is not two files, but a single file. Somehow you have ended up with a file named README.md a_text_file.txt in your working folder. This happens to me periodically when I fat-finger a vi command or a shell redirection. Or possibly when I write a script where whitespace is a delimiter, but only sometimes (like bash) and it ends up treating a list of paths as a single string instead of an array.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...