Git problem when try to discard changes
I do git status:
# modified: xxx/yyy/something.PNG
# modified: xxx/yyy/something-l.PNG
then git checkout xxx/yyy/something.PNG and xxx/yyy/something-1.PNG but when i do git status again 开发者_如何学Goit shows again:
# modified: xxx/yyy/something.PNG
# modified: xxx/yyy/something-l.PNG
Im using Snow Leophard
Thanks
I'm fairly sure that you've clipped the output of git status. Those modified files were in the "changes to be committed" section. They're in the index (staging area); that is, you probably at some point ran git add xxx/yyy/something.PNG
or maybe just git add .
or git add -u
.
git checkout <path>
checks out the version of the given path from the index, not from the current commit. If you want to get back to the version from the current commit, use:
git checkout HEAD xxx/yyy/something.PNG
HEAD
refers to the current commit.
Maybe you already staged your changes. git diff
shows nothing while git diff --staged
shows that you've changed the files.
In that case, you'll have to unstage them using git reset HEAD xxx/yyy/something.PNG xxx/yyy/something-l.PNG
.
Otherwise another program may change the files.
EDIT:
According to your comment below, the file mode of the files is 755
. So it seems like Windows touched them. Try chmod 644 xxx/yyy/something.PNG
.
I solved the problem. I deleted .git
subfolder on /xxx/yyy/
and everything is ok now.
精彩评论