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
243 views
in Technique[技术] by (71.8m points)

Git asks me to commit or stash changes on checkout master, even though all changes were committed?

I have two branches locally, master and Berislav. The latter is currently active, and I have committed all the changes. When I try to checkout to master, I get the following message:

error: Your local changes to the following files would be overwritten by checkout: [list of files changed in the active branch] Please, commit your changes or stash them before you can switch branches. Aborting

However, everything else I tried -- commit, status, merge -- tells me that there's nothing to commit (working directory clean). What do I need to do to get to my master branch?

EDIT: When I try git stash, I'm getting:

error: feeding unmodified [file path] to diffcore

for all the files listed in the error above.

question from:https://stackoverflow.com/questions/8709001/git-asks-me-to-commit-or-stash-changes-on-checkout-master-even-though-all-chang

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

1 Reply

0 votes
by (71.8m points)

I encountered a similar problem today. git status wasn't listing the files which checkout was complaining about. I did a:

git checkout -- path/to/file

And that undoes any changes to the file.

An even easier way to undo all unstaged changes on current working directory [1]:

git checkout -- .

[1] - Be warned - you will lose any other unstaged changes you were working on (if any). If you don't know what you are doing, then keep a backup of the files you were working on :)


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

...